Linking C from C++ in OS X Mavericks

后端 未结 3 1143
温柔的废话
温柔的废话 2021-01-04 17:51

Having transitioned to OS X Mavericks and XCode 5.0.1, I can no longer gracefully link compiled C files (output from gcc) to a C++ project (output from g++).

The off

3条回答
  •  耶瑟儿~
    2021-01-04 18:43

    Adding a "-x c" (without quotes) before "vec.c" should fix it.

    If you compile multiple .c/.cpp files in the same line you can use "-x c" or "-x c++" before each list of C or C++ filenames to switch context appropriately. For example:

    g++ -x c  alpha.c beta.c  -x c++  gamma.cpp
    

提交回复
热议问题