Skip to content
Advertisement

g++ custom dynamic library linking error undefined symbol

Ok, I’m looking for a solution for 2 days now. I didn’t find anything to solve my problems.

What is currently going on? So, I tried creating a dynamic library (.so) on Linux Mint Maya 13 with g++.

foolib.h:

JavaScript

foolib.cpp:

JavaScript

main.cpp:

JavaScript

I compiled these files with these instructions:

libfoo.so:

JavaScript

foo:

JavaScript

Creating libfoo.so works without any errors, but foo throws undefined reference ´foo’. I copied sample code from several web pages and tried to compile it, always the same result.

The funny is, I can link do libdl.so (-ldl), load my .so and my function. What am I doing wrong?

I hope I could formulate my question correctly. Please tell me if I didn’t. : )

Advertisement

Answer

You should use:

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement