EvilZone
Programming and Scripting => Projects and Discussion => : kenjoe41 August 15, 2013, 12:27:42 PM
-
I am working on a project now in C++ which i want to be portable for windows, Linux and Macos.
Problem is the auto detection of the os so as to locate certain file which are stored in different paths as per the OS.
Right now the project works just fine but it requires the file path as an arg which might be pretty difficult for non-experienced users.
Am trying to stay away from the #include <windows.h> header which might restrict the code to windows and environ() isn't working its magic to my liking.
Any code snippet is welcome.
-
That's very poor practice with compiled languages.
Try detecting the os at compile time, or distribute 3 separate source codes/binaries
-
It is impossible to make a compiled program portable on run time. It can only be done in compile time, bro.
Different systems have different executable structures. What is compiled for windows, will not work for linux and vice versa, even if you don't use <windows.h>.
However, scripts, such as Python, can be portable between systems.
You will have to think of something better.
-
My only solution is to try code something for each OS then distribute different binaries.
OR better just distribute the source code for the different OS so people can compile it themselves.
Thanks.
-
Google "premake4" or "CMake" for a good compile time multi OS thingy :).
do some compiler commands to see if the build is OSX, Win, *nix or whatever.
CMake is also implemented for most IDE's
-
CMake is also implemented for most IDE's
If you mean most IDEs like Code::Blocks, am right on it now.
-
It is impossible to make a compiled program portable on run time. It can only be done in compile time, bro.
Different systems have different executable structures. What is compiled for windows, will not work for linux and vice versa, even if you don't use <windows.h>.
However, scripts, such as Python, can be portable between systems.
You will have to think of something better.
Wrong I did it in OLink. But it is a bit of a pain and probably too much trouble for most things. But you can do it. It just requires writing your own binary loader for say, ELF binaries, and then loading them yourself on each platform. You will need a slight bit of start up code on each platform though.
-
Wrong I did it in OLink. But it is a bit of a pain and probably too much trouble for most things. But you can do it. It just requires writing your own binary loader for say, ELF binaries, and then loading them yourself on each platform. You will need a slight bit of start up code on each platform though.
Doable while not very practical.
-
For the project am working on, it's just not worth the sweat as of now.
Just gonna bundle install scripts with the source code for both Os x and Linux.
I will try that with a more promising project and alot of time on my hands.