Archived

This topic is now archived and is closed to further replies.

RamboBones

Using gcc

Recommended Posts

Okay I have a couple of questions for using gcc. I''ve spent hours looking in the docs for help on these but I couldn''t find anything. First of all I''m using the windows version of gcc, just so nobody gives me any unix/linux commands :D. Anyway I want to be able to compile a .c file into a flat binary file, as in the pure compiled code with no .exe headers or stuff, like a .com file. I also read that somewhere that you can tell gcc to use either 16 bit or 32 bit compiling/linking is this true? And if it is how do you do it? I would like to say that I''m not really a beginning programmer, I''ve been using VC++6.0 for many years but would like to do this in gcc, unless anybody knows how the above things can be done in VC++6.0.....

Share this post


Link to post
Share on other sites
You might run into difficulties with the 2.95 mingw32 package, I was attempting to use that (it''s actually the linker ld which produces the flat binary from the .o files) to do the exact same thing, you should be able to compile your c to a collection of .o and then do:

(e.g. this is taken from OS FAQ)

GCC -c my_kernel.c
LD my_kernel.o -o kernel.bin -oformat binary -Ttext 0x100000

However, with the mingw32 distro, ld crashes when you try this (I''m assuming it is compiled with *only* PE support).

DJGPP the DOS version of gcc is supposed to work, but I could never be bothered to set it up.

You might be lucky and the newer versions of mingw32 (or some other windows version) will work.

Share this post


Link to post
Share on other sites
[ahem]...

open dos box
run gcc_dir\gcc -c src_dir\all_your_libs_and_objects.c
run gcc_dir\gcc src_dir\*.o -o output_dir\filename.exe

actually, it''s the same thing as in unix...
and 16bit compilation can be done by adding the -m16 argument (it''s m16 like machine-register-lenght 16, not that damn rifle)

Share this post


Link to post
Share on other sites
quote:
Original post by 666_1337
[ahem]...

open dos box
run gcc_dir\gcc -c src_dir\all_your_libs_and_objects.c
run gcc_dir\gcc src_dir\*.o -o output_dir\filename.exe

That would result in a PE binary. Precisely what the OP didn''t want. Read the question again.

Share this post


Link to post
Share on other sites