Click to See Complete Forum and Search --> : WARNING: Extremely Basic Compiling Question.


Nailz
06-15-2001, 02:54 PM
Don't say I didn't warn you but...

If I have the source code (a .c file) and would like to compile it into a binary...what do I need to do?

I'd like to compile it into an .exe for use on Windows to be honest, but will settle for a Linux binary as well...

Any straightforward answer?

I'm running RH 7.1 at home and Windows 2000 at work...

KT
06-15-2001, 03:04 PM
"g++ -Wall -o <binary output file name> <source file>"

This will not work in windows, to make your code work in windows you must compile it in windows.

Also, I am assuming the g++ compiler is installed on your system.. if it isn't you must download it.

-Wall shows any compilation errors
-o tells it to create a binary named <binary output file name>

fancypiper
06-15-2001, 03:04 PM
I do it this way.

./configure; make; make install

That configures it, compiles it and installs it on my system.

ZacMacCrac
06-15-2001, 03:47 PM
Originally posted by fancypiper:
<STRONG>./configure; make; make install

That configures it, compiles it and installs it on my system.</STRONG>

Yes, but only if there is a make file for it also. If you have just a plain source file (.c, .cc or .cpp if it's a C/C++ source) you will need to start the compiler directly as KT explained above.

fancypiper
06-15-2001, 04:48 PM
Hmm... I never have had just plain source. All my downloads have had make and configure in the tarball. I never have had to edit the make or the install files, even though I do read the readme, etc.

MandK_10
06-15-2001, 05:14 PM
Hmm... I never have had just plain source. All my downloads have had make and configure in the tarball

This guy is writing his own code, not downloading it.

sans-hubris
06-15-2001, 06:11 PM
You can get GCC for Windows. I recommend getting MinGW (http://www.mingw.org/). It's a very basic compiler without a lot of fluff like like Cygwin (http://www.cygwin.com/). There are cross platform GCC compilers out there that will let you work on one platform (e.g.) but compile for other platforms (e.g. Windows.) I haven't played with those yet so I can't say much about them.

GCC, however, is used pretty much the same way on all platforms so the above commands that KT gave you will work on Windows as long as you have the GCC stuff in your path.

Nailz
06-18-2001, 09:03 AM
Actually this is code sent to me by an associate. I installed Cygwin on my work pc (fluff and all) before I was able to get home and just gcc on my linux box.... seems to work just fine except for the fact that I wasn't given the INCLUDE files. Now I have to go back and get those and try recompiling.

Blake
06-19-2001, 12:45 AM
Just to put the last nail in the coffin: If I had a C source file called HelloWorld.c and wanted the binary to be called HelloWorld I would compile it like this:


gcc -g HelloWorld.c -o HelloWorld

The -g put's debug information into the binary file so you can step through the code with the debugger. (Take it out if you like)

Have fun