How to link a C++ shared library with gcc
I have seen a GCC link with a C++ shared library, but I am not able to reproduce it on my own. So first I create a C++ library with a testfunction:

    g++ -shared -o libtest.so test.c

Then I have a test main function which calls the library function and compile it like this

    gcc -o prog.out main.c -L. -ltest

Then i receive the error

    undefined reference to 'testfunc'

which i think is caused by different refernce in the library ... C names the function testfunc and C++ names the function [some stuff]__testfunc[maybe again some stuff].

I have also tried to use

    gcc -o prog.out main.c -l:libtest.so

but this results in the same error.

Therefore, my question is: How is it possible to link a c++ library with gcc to a c file?

How to link a C++ shared library with gcc
===

I have seen a GCC link with a C++ shared library, but I am not able to reproduce it on my own. So first I create a C++ library with a testfunction:

    g++ -shared -o libtest.so test.c

Then I have a test main function which calls the library function and compile it like this

    gcc -o prog.out main.c -L. -ltest

Then i receive the error

    undefined reference to 'testfunc'

which i think is caused by different refernce in the library ... C names the function testfunc and C++ names the function [some stuff]__testfunc[maybe again some stuff].

I have also tried to use

    gcc -o prog.out main.c -l:libtest.so

but this results in the same error.

Therefore, my question is: How is it possible to link a c++ library with gcc to a c file?
