Saturday, May 22, 2010

Writing programs for Linux?

Hi, say I have a program in standard C++, and it runs on the PC and Mac currently, but I want it to run on Linux as well, how do I decide on a distro to test it on? what distro do I compile it on? I don't want to install 50 distros on a pc just to make sure it works, any help?

Writing programs for Linux?
So, the question you are asking is how to do I run a C++ Windows executable on a Linux machine.





There are several ways to think about this.





1. If you have the C++ source code, you can copy the source files onto the Linux machine and compile it yourself. For example, you can use g++ on Linux (it is free) to compile C++ code.





2. If you don't have the source code, see if the program comes with a binary for linux





3. If you can't do that. You can install a windows emulator on the Linux machine. Then you can run window programs. Here is a link for such an emulator - http://www.winehq.org/





Have fun.
Reply:The distro won't matter because they'll all come with the same gnu compiler.





A distro is nothing more than a "branded" version of GNU/Linux.





The Data Analyst - http://www.squidoo.com/thedataanalyst
Reply:looks like ubuntu is the winner and the opensuse the 2nd :)
Reply:-- QUOTE --


Hi, say I have a program in standard C++, and it runs on the PC and Mac currently, but I want it to run on Linux as well,


-- END Q --





If it is standard C++, it will work on Linux as well.





-- QUOTE --


how do I decide on a distro to test it on?


-- END Q --





Doesn't matter. All of them are Linux. Good bet it will work on other Unices as well.





-- QUOTE --


I don't want to install 50 distros on a pc just to make sure it works, any help?


-- END Q --





Just test your programs on _something_. It really doesn't matter which one. They are all Linuxen.





-- QUOTE --


How do I compile my programs for distribution onto the Linux platform?


-- END Q --





You know it's easier _not_ to compile, right? Source tarballs are a common form of distribution, and anyone can do a ./configure make make install sequence. So basically look up how to create configure and makefiles. That will tell you how to setup ./configure make for your project. Almost everyone on Linux has the tools needed for the compile (gcc and libraries). So they will typically do ./configure make make install.





Compiling is a bit tricker. Actually, typically, you don't just compile, but also distribute in the appropriate package management solution. Google up the entire process as it is a bit more involved. It's also distribution specific. Example: All debian based Linux distros use apt. suSE has YAST. There's RPMs, typically associated with Fedora and a few others.
Reply:When I downloaded Ubuntu it didn't have a C complier (gcc)on the LiveCD, I had to download it separately.





I would download PCLinuxOS because at I know that is more likely to include a complier with the LiveCD.


No comments:

Post a Comment