SQLite Forum

Compiling without the amalgamation process
Login
g++ forces compilation with the C++ preprocessor irrespective of the file extension, and automagically adds the libstdc++.a (and maybe others) to the linkage.

In "plain english" that means that "g++ <other stuff>" is pretty much merely a magical incantation/syntactical sugar for "gcc -x c++ -lstdc++ <other stuff>"

To have g++ choose the compiler preprocessor based on the file extension you have to turn off the -x option and allow the file extension to determine the language preprocessor to use.

You do this by using "g++ -x none" which will revert to using the standard rules for determining which compiler to use but still include the libstdc++.a in the link step if this g++ invocation invokes the linker.

"extern C" merely controls external symbol name mangling.  Declarations which are "extern C" will use industry-standard C-style name mangling no matter what language preprocessor is being used -- so for example if you are using the C++ language preprocessor then C-style name mangling will be performed rather than C++ name mangling.  "extern C" does not affect the choice of language preprocessor used by the compiler set.