Why this does not work, file test.c
:
#include <event.h>
int main(void)
{
event_init();
return 0;
}
Then:
gcc -o test.o -c test.c
runs OK, but
Link:
g++ -o test -levent test.o
produces
test.o: In function `main':
test.c:(.text+0x5): undefined reference to `event_init'
collect2: ld returned 1 exit status
So it cannot be linked as C++
. How to solve this? I need to link it as C++
and compile as C
.