I'm figuring out how to compiler C code with GCC. I got it to compile a simple Unix executable that runs on my computer. Is there a way to get GCC to compile programs that can be ported to different computers, and don't only work on your own machine? I want to know this because I would like to develop open source software, and make projects that I'm working on (or contributing to) available on the internet.
Compiling with GCC
Started by DarkLordoftheMonkeys, Jan 04 2010 08:39 PM
4 replies to this topic
#1
Posted 04 January 2010 - 08:39 PM
Life's too short to be cool. Be a nerd.
|
|
|
#2
Posted 04 January 2010 - 11:38 PM
I'm not sure what your asking, but I will try to help.
GCC can't produce one single executable that will run on many different operating systems. If you compile something for Linux, it will not run on Windows. If you want to compile Windows executables under GNU/Linux, I think it can be done (maybe with mingw), but I have not done it before.
GCC can't produce one single executable that will run on many different operating systems. If you compile something for Linux, it will not run on Windows. If you want to compile Windows executables under GNU/Linux, I think it can be done (maybe with mingw), but I have not done it before.
Root Beer == System Administrator's Beer
Download the new operating system programming kit! (some assembly required)
Download the new operating system programming kit! (some assembly required)
#3
Posted 05 January 2010 - 02:52 AM
To add to what Guest said, if you want to give you program to someone else to run then you have to make sure that you include any files that that the program relizes on are sent along with it such as .dlls' or .os files that are required to run the program.
#4
Posted 05 January 2010 - 10:31 AM
I believe it's possible to compile for a different platform, but I'm not sure how, exactly, you go about it.
#5
Posted 05 January 2010 - 11:01 AM
Yes, GCC can compile executables for other architectures, and some platforms, but it cannot target windows. See this to learn how to make a cross compiler.
To compile for windows, you can install wine and install mingw inside wine. Then you need to set:
To compile for windows, you can install wine and install mingw inside wine. Then you need to set:
- 'cc' to the path of the mingw gcc
- 'cxx' to the path of the mingw g++
- 'as' to the path of the mingw as (this is the assembler)
- 'ld' to the path of the mingw ld (this is the linker)


Sign In
Create Account


Back to top









