これが機能しない理由、ファイル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。