cannot specify -o with -c or -S and multiple compilations
Gnatinator

I am using Djgpp and Rhide and when I try to complie a program it gives me this error message:

cannot specify -o with -c or -S and multiple compilations

Does anyone here have any idea what that means? ???

Please help me.

Bob

That's because the options don't really make sense to combine. -o tells gcc to link to an executable file, but -c tells gcc to compile to object code only and not create an executable (IIRC). -S tells gcc to not link, but rather dump the generated assembly code in some file.

23yrold3yrold

I used to get this error because my source file names had spaces in them. So "Main Code.c" would be treated as two parameters, and generate your error. "MainCode.c" is valid though. DOS is funny like that ;) Does that help?

Gnatinator

wierd....

I tried compiling my program again a few hours later and it worked.

I did not do anything to it...

I have no idea what went wrong, but apparently it was for no reason....fixed. :-/

That was an odd experience.

Can anyone comment on this?

StevenVI

Yes, I can, having read far too much about gcc ;).

-o means the next parameter is the output file.
-c means to make object code from source.
-S means to make asm code from source.

You can't compile multiple input files into one output file, unless the output is an executable file. When you use '-c' or '-S' it's telling the compiler to make non-executable code. This means that the following compile line is acceptable:

gcc -c myfile.c -o myexe.o

But these ones are not:

gcc -c myfile1.c myfile2.c -o myfiles.o
gcc -S myfile1.c myfile2.c -o myfiles.s

Edit: Note that '-S' is a capital S, '-s' (with lowercase) makes the compiler not include a bunch of extra information in the output, and is for use with release builds.

-Sven

Thread #198534. Printed from Allegro.cc