Reputation: 1305
I have the following files on a linux VM:
gc.h
gc.c
test.c
test.out
I run the command in terminal:
gcc -g test.c gc.c gc.h -o test.out
Everything compiles. I then run the same files (I copied them over) and run the command on my OSX terminal:
gcc -g test.c gc.c gc.h -o test.out
I then get the following error:
clang: error: cannot specify -o when generating multiple output files
Is there a simple reason why I am getting this error? I don't understand as I am not generating multiple files? I also googled this, but couldn't find anything relevant.
I have appreciated your clues. I get now that it has to do with the fact that I am running OSX 10.9 Mavericks and xcode 5.0.2. So now I am in the process of trying to switch over to gcc48. So I thought doing it would be easiest with brew install gcc48
. I just did a major update with brew last week and I saw this message:
Error: No available formula for gcc48
Searching taps...
homebrew/versions/gcc48
Anyone see this before? I am somewhat not very experienced with the brew tool. What does this mean? Yes, I googled this, but just don't seem to have a lot of luck today. Then, I found this Homebrew install specific version of formula? and I think I got it working. But not quite sure why the normal command wouldn't work as intended?
Upvotes: 3
Views: 2014
Reputation:
Your problem is that you're trying to compile a header file:
gcc -g test.c gc.c gc.h -o test.out
^^^^
clang is interpreting this as an attempt to precompile the header. While a useful thing to do in general, this isn't compatible with also compiling your application in the same breath.
Remove that from the compiler command line and you'll be fine.
Upvotes: 4
Reputation: 21354
OSX uses clang not gcc in their gcc command. Just do a gcc --version on both your linux vm and your osx machine and you'll notice that they are different compilers.
You could install the real gcc using brew (e.g., brew install gcc48
) and then use that on your osx if you want to get the exact same behavior as on your linux vm.
Upvotes: 2