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