今天遇到了一个问题
文件: main.c test1.cpp test1.h
不能编译。
g++ -c main.c
g++ -c test1.cpp
g++ main.o test1.o -o a
因为两个源文件的后缀,一个属于c,另外一个属于c++。所以出现了这样一个问题:
Undefined symbols for architecture x86_64:
"_first", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
都改成.c或者.cpp就行了。