Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The symbol is in the file. I verified it using nm & grep but I still get the undefined symbol error when I run the compiled application. Other symbols in the shared library are working just fine. The header file declares it as extern and it is not in a conditional pre-processor block. I'm new to c/c++ so any experience with something like this would be appreciated.

There are a ton of related questions on StackOverflow, but everyone is listing source files and headers that don't mean anything to the actual context of the question. This is a general programming question: Why can't g++ link the symbol into my compiled application? Header definition checks ok, the symbol is in the shared library, and other symbols are working properly.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
153 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to set your LD_LIBRARY_PATH environment variable to include the path to your development version of the library. This will ensure the run time linker (ld.so) will find it when you run your application.

Your build settings are fine but they don't affect what happens at run time. There are ways to "bake" paths into the executable at build time if you really want to. See the man page for ld.so to see how it searches for libraries.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...