Compiling C and C++ files together using GCC

后端 未结 6 933
[愿得一人]
[愿得一人] 2020-12-07 16:38

I\'m trying to compile C and C++ sources together using GCC.

gcc -std=c++0x test.cpp -std=c99 test.c -lstdc++

Now, this works fine, except that

6条回答
  •  再見小時候
    2020-12-07 17:40

    Compile the files separately, link with g++

    gcc -c -std=c99 -o file1.o file1.c
    g++ -c -std=c++0x -o file2.o file2.cpp
    g++ -o myapp file1.o file2.o
    

提交回复
热议问题