为什么这不起作用,文件test.c:
#include <event.h>
int main(void)
{
event_init();
return 0;
}
然后:
gcc -o test.o -c test.c运行正常,但是
链接:
g++ -o test -levent test.o生产
test.o: In function `main':
test.c:(.text+0x5): undefined reference to `event_init'
collect2: ld returned 1 exit status
所以它不能链接为C++. 如何解决这个问题?我需要将其链接为C++并编译为C.