Error In Dlopen Undefined Symbol
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company dlopen error undefined symbol root Business Learn more about hiring developers or posting ads with us Stack Overflow Questions dlopen undefined symbol c++ Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million
Dlopen Failed Undefined Symbol
programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Receive “undefined symbol” error when loading libary with dlopen up vote 16 down vote favorite 8 I'm writing some code that
Error Undefined Reference To Dlopen
uses dynamic shared libraries as plugins. My command line for building the shared libraries looks like: cc -shared -fPIC -o module.so -g -Wall module.c Within the module, I can call functions that are in any other shared library that has been loaded within the main executable. However I cannot access (exported) functions that are in the executable itself (I get undefined symbol errors). My call to dlopen looks like this: void *handle = dlopen(plugin, dlopen undefined reference RTLD_NOW); Can anyone please advise how my module can call back to my executable, without having to put all of the executable's utility functions into yet another shared library? shared-libraries dlopen share|improve this question edited Feb 28 '12 at 2:20 sholsapp 4,97433247 asked Jan 26 '09 at 17:29 Alnitak 213k42278351 add a comment| 3 Answers 3 active oldest votes up vote 26 down vote Correct solution is to add -rdynamic to the link command of the main executable. This will add appropriate option to ld (which, when using GNU ld, happens to be --export-dynamic). Adding --export-dynamic directly is technically incorrect: it's a linker option, and so should be added as -Wl,--export-dynamic, or -Wl,-E. This is also less portable than -rdynamic (other linkers have an equivalent, but the option itself is different). share|improve this answer answered Jan 27 '09 at 7:31 Employed Russian 86.2k14118171 This solution also applies when using Boost Extensions as boost shared_library class is using dlopen (on Linux) to load library. –Farrukh Arshad Jan 3 '13 at 7:04 add a comment| up vote 5 down vote accepted I've found the answer myself. I had to add the --export-dynamic flags to the link options for the main executable. When creating a dynamically linked executable, add all symbols to the dynamic symbol table. The dynamic symbol tab
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Dlopen Library
this site About Us Learn more about Stack Overflow the company Business Learn dlsym undefined symbol more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question dlopen example x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up http://stackoverflow.com/questions/480617/receive-undefined-symbol-error-when-loading-libary-with-dlopen dlopen - Undefined symbol error up vote 3 down vote favorite 1 I'm using dlopen to load a shared library at run time dlopen("SharedLibarary1.so", RTLD_NOW | RTLD_GLOBAL); In that shared object I refer to a const char* defined in another shared library "SharedLibarary2.so". The Executable, and both the libraries are built using -rdynamic. But I still get the run time error when using http://stackoverflow.com/questions/12975673/dlopen-undefined-symbol-error dlopen: "/usr/lib/SharedLibarary1.so: undefined symbol" and points to the mangled const char* has the undefined symbol. Whith GDB "info share" I can see that the second library is not loaded at the point of the error. How ever that problem goes away if I do a dlopen on the second library before I do on the first library. Is there a better way to force the loader to load the second library for the unresolved symbol? c++ c linux dlopen shared-libraries share|improve this question edited Oct 19 '12 at 13:59 Sam Miller 18.1k34373 asked Oct 19 '12 at 13:47 Sak 12929 1 yes. Don't make the library you load rely on something that will only be linked in by another library that you will load using dlopen(). Use a shared object that is loaded the regular way that has that symbol. Does using RTLD_LAZY help by the way? –CashCow Oct 19 '12 at 13:56 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted When building a shared library, you can link another inside, e.g. like gcc -shared -rdynamic lib1*.pic.o -lshared2 -o SharedLibrary1.s
NAME top dlclose, dlopen, dlmopen - open and close a shared object SYNOPSIS top #include