How to make C++ projects computer independent. Detailed instructions needed.
Title says it all. I have "le project" that I want to compile on my computer. Send it to a friend on a different computer but same OS (linux) and it work. Most of the time it will say "Cannot Run this program!". It would also be good to know if there was any way to make it OS independent, but Windows will most-likely complain. So just this for now. How to package a system independent C++ program.
|
C++ is not intended for that...Java is. Dotnet should be, but...I dont trust it...at all.
What you need is a runtimer that is made for the target OS/platform and program against that... The thing lies in the compile...at compile time, the links get made for the OS/platform in use at compile time. Just what program is it, by the way? Thor |
If you compile it with static libraries there's a good chance your Linux friend will be able to run it (possibly 32-bit with static libs if you're running a 64-bit OS and he's not). Getting it to run on another OS is another matter entirely though, and needs a cross-platform language more like Java (as mentioned above).
|
depends on the project itself. Creating GUIs will make it really hard, probably you will need wxWindows or similar.
You cannot have system independent packages, because all the installable packages are designed for a specific os. Linux and MS Windows are really different. You can also try wine on linux |
Quote:
Quote:
Quote:
|
Quote:
|
another issue not mentioned is that between windows, mac, linux, bsd etc.. they all use different executable formats
linux,bsd and a lot of *NIX operating systems uses the ELF binary format, mac uses the Mach-O format windows uses the PE (portbale exececutable) format so right there, you would still have to compile the program for the target system, not to mention each system has a different API, which would require porting the program. |
You will get the best portability with using something like Java or .NET/Mono.
If you want to stick with C++ you should try to use an application framework that is available on all platforms you want to provide your software for, for example Qt. You still will have to compile for any platform you want to use, but the work need to port to a different platform should be as minimal as possible if you want to use C++. |
The best ways to have an application that runs on multiple operating systems and distros:
Some people just write their code for Linux and require that the user run it with cygwin. That's acceptable for some things, but it's not a very graceful solution in most cases. It's really meant for software that from the beginning wasn't intended to run on Windows. As a final point, remember how much of a pain it is to even have the capability of compiling C++ code on/for Windows and OS X, regardless of if your code can compile for those OSes. Kevin Barry |
Quote:
Did you mean OS-independent ? CPU architecture independent ? |
Quote:
Quote:
CPU architecture may be what I am looking for. What I am looking for specifically is a way to make C++ projects that are built on linux OS to run other linux OS's, different computers, different systems, different, but the same general linux OS. I don't understand what is confusing to you here. Quote:
Quote:
Thanks for everyone that has replied. Again, I am not looking for OS independence, NOT Windows to Mac to Linux and back, No. Just Linux to linux. One compilation that will work for most linux computers. I, again, I UNDERSTAND that Java and other languages have already done this, that is why I am trying to make it work for C++. Its a headache and painful, yes, but someone should figure out how to do it, thats what I am trying to do. |
Quote:
you have to specify them in the right order and you have to specify every dependency recursively While what you say may be true for certain massive applications with hundreds of dependencies, or applications that are linking in other static libraries that you've compiled, that are based on other static libraries that you've compiled...I think that's more the exception than the rule. |
Quote:
Quote:
Kevin Barry |
Quote:
|
Quote:
I have a laptop and a desktop computer. One is Intel-based, the other - AMD-based. Choosing 'i586' architecture during compilation makes my program run on both computers. So, on the set of the two computers the program is computer-independent. OTOH, your program might need, say, 16GB of virtual memory. And two computers with identical motherboards and identical CPUs may be different from the point of the program - because in one of them there will be not enough virtual (let alone physical) memory. |
All times are GMT -5. The time now is 02:50 AM. |