Gabriel Appugliese
Gabriel Appugliese

Reputation: 43

C++ compilation clang error multiple output files

I can't figure out why i can't compile my program with

    g++ -std=c++0x main.cpp Sale.h iProduct.h -o w7

every time i try and compile with this command i get a clang error

    clang: error: cannot specify -o when generating multiple output files

the program complies fine as a.out and i know i could just rename the a.out file and be on my way but i would like to know why I'm getting this error and how i should fix it. Thanks

Upvotes: 4

Views: 1796

Answers (1)

fghj
fghj

Reputation: 9404

why I'm getting this error and how i should fix it may I ask why do the .h files affect it?

Because of recent versions of gcc can compile heaader files, Example:

g++ test.h -o out
file out
out: GCC precompiled header (version 014) for C++

It(gcc) produce precompiled files (https://en.wikipedia.org/wiki/Precompiled_header) in this case.

So when you compile .cpp file and header at the same time, it can not decide what produce as output precompiled headers, or elf executable.

Upvotes: 2

Related Questions