Jump to content

Compiling with GCC

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
DarkLordoftheMonkeys

DarkLordoftheMonkeys

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
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.
Life's too short to be cool. Be a nerd.

#2
Guest

Guest

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 3,414 posts
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.
Root Beer == System Administrator's Beer
Download the new operating system programming kit! (some assembly required)

#3
Feral

Feral

    Programmer

  • Members
  • PipPipPipPip
  • 162 posts
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
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I believe it's possible to compile for a different platform, but I'm not sure how, exactly, you go about it.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
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:

  • '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)