인터넷을 겁나 뒤졌는데 -lstdc++ 과는 달리 차이가 좀 있는 것 같다.
http://stackoverflow.com/questions/172587/what-is-the-difference-between-g-and-gcc
가장 마음에 드는 답변.
로그 찍어보고 탐구하기엔 시간이 부족해.
gcc -std=c++0x -lstdc++ 로 컴파일 하면 간지나 보였는데
걍 g++로 가는게 맞는 것 같다.
GCC: GNU Compiler Collection
- Referrers to all the different languages that are supported by the GNU compiler.
gcc: GNU C Compiler g++: GNU C++ Compiler
The main differences:
- gcc will compile: *.c/*.cpp files as C and C++ respectively.
- g++ will compile: *.c/*.cpp files but they will all be treated as C++ files.
- Also if you use g++ to link the object files it automatically links in the std C++ libraries (gcc does not do this).
- gcc compiling C files has less predefined macros.
- gcc compiling *.cpp and g++ compiling *.c/*.cpp files has a few extra macros.
Extra Macros when compiling *.cpp files:
#define __GXX_WEAK__ 1
#define __cplusplus 1
#define __DEPRECATED 1
#define __GNUG__ 4
#define __EXCEPTIONS 1
#define __private_extern__ extern
|
answered Oct 6 '08 at 1:55
|
|
|
|
gcc
by passing-lstdc++
parameter. – Denilson Sá Aug 23 '10 at 0:13gcc -lstdc++
will still not get you the same behavior asg++
. We put all of that language-specific behavior into its own driver for a reason, that's what it's there for. :-) – Ti Strga Jan 28 at 21:03-lstdc++
, as there will be missing dependencies on math, RTTI, and exception information. Whether a given test case links or fails will depend on the operating system and which C++ features are used by the test case, which again is why all of that knowledge is built into the g++ driver instead of being left up to the user to figure out. – Ti Strga Jan 29 at 15:38gcc -lstdc++
on other OSes, especially when the target is an embedded platform. Fortunately, that's why we ship a g++ in the first place. – Ti Strga Jan 29 at 15:40g++ -dumpspecs
. This shows exactly what they use to link with and options set to the backend. – Loki Astari Jan 29 at 16:38-dumpspec
on (for example) a cross compiler targeting an embedded system, you will see the differences. There are more than just linker differences... which again, is what your answer was about (preprocessor macros, include paths, multiple runtime libraries). We seem to be talking past each other, but as a former GCC maintainer, I assure you I am familiar with what the frontends are and are not. – Ti Strga Jan 29 at 17:02