I have one function extern "C" int ping(void) in a C++ "static-library" project. Now, I would like to write a simple Hello-World C program that will call this function int x = ping();.
I use g++ / gcc but I cannot link the C executable with C++ shared library. Please, how can one do that? Could you please provide exact gcc commands?
Edit:
g++ -c -static liba.cpp
ar rcs liba.a liba.o
gcc -o x main.o -L. -la
and get:
./liba.a(liba.o):(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status