Dlopen So Error 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
Dlopen Error Undefined Symbol Root
this site About Us Learn more about Stack Overflow the company Business Learn dlopen undefined symbol c++ more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
Dlopen Failed Undefined Symbol
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 dlopen undefined reference Receive “undefined symbol” error when loading libary with dlopen up vote 16 down vote favorite 8 I'm writing some code that 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 dlopen library 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, 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.1k14118171 This solution also applies when using Boost Extensions as boost shared_libra
Canal
Dlopen Example
-0500 Hi Vassili, $ echo _ZTV10IntKeyCntr | c++filt vtable for IntKeyCntr dlopen dlsym example This usually means that you are missing the implementation of one of your virtual function or that
Dlopen C++
you are missing the dictionary. Cheers, Philippe. On 4/14/11 1:24 PM, Vassili Maroussov wrote: > Dear ROOTers, > > I'm getting the "undefined symbol:"error while trying to http://stackoverflow.com/questions/480617/receive-undefined-symbol-error-when-loading-libary-with-dlopen load in ROOT session a library with 2 very simple classes. I have no idea > what is a reason. File are attached, the session log is below. Can someone help me? > > Regards, > > Vassili > > ----------------------- > [vmarouss_at_Ezhik-HDX18 IntKeyList]$ > [vmarouss_at_Ezhik-HDX18 IntKeyList]$ uname -a > Linux Ezhik-HDX18 2.6.35.12-88.fc14.x86_64 #1 https://root.cern.ch/root/roottalk/roottalk11/0572.html SMP Thu Mar 31 21:21:57 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux > [vmarouss_at_Ezhik-HDX18 IntKeyList]$ make clean > [vmarouss_at_Ezhik-HDX18 IntKeyList]$ make > g++ -O2 -Wall -fPIC -pthread -m64 -I/usr/local/ROOT/pro/include -c IntKeyList.cpp > Generating dictionary IntKeyListDict.cpp... > IntKeyListDict.cpp done > g++ -O2 -Wall -fPIC -pthread -m64 -I/usr/local/ROOT/pro/include -c IntKeyListDict.cpp > g++ -shared -O2 -Wall -fPIC -pthread -m64 -I/usr/local/ROOT/pro/include IntKeyList.o IntKeyListDict.o -L/usr/local/ROOT/pro/lib > -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread > -lm -ldl -rdynamic -o libIntKeyList.so > libIntKeyList.so done > [vmarouss_at_Ezhik-HDX18 IntKeyList]$ root > ******************************************* > * * > * W E L C O M E to R O O T * > * * > * Version 5.28/00b 14 March 2011 * > * * > * You are welcome to visit our Web site * > * http://root.cern.ch * > * * > ******************************************* > > ROOT 5.28/00b (branches/v5-28-00-patches_at_38394, Apr 14 2011, 17:55:00 on linuxx8664gcc) > > CINT/ROOT C/C++ Interpreter version 5.18.00, J
of a program. They're particularly useful for implementing plugins or modules, because they permit waiting to load the plugin until it's needed. For example, the Pluggable Authentication Modules (PAM) system http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.html uses DL libraries to permit administrators to configure and reconfigure authentication. They're also useful for implementing interpreters that wish to occasionally compile their code into machine code and use the compiled https://linux.die.net/man/3/dlopen version for efficiency purposes, all without stopping. For example, this approach can be useful in implementing a just-in-time compiler or multi-user dungeon (MUD).
In Linux, DL libraries aren't actually special from undefined symbol the point-of-view of their format; they are built as standard object files or standard shared libraries as discussed above. The main difference is that the libraries aren't automatically loaded at program link time or start-up; instead, there is an API for opening a library, looking up symbols, handling errors, and closing the library. C users will need to include the header fileconst char *symbol); int dlclose(void *handle); Link with -ldl. Description The four functions dlopen(), dlsym(), dlclose(), dlerror() implement the interface to the dynamic linking loader. dlerror() The function dlerror() returns a human readable string describing the most recent error that occurred from dlopen(), dlsym() or dlclose() since the last call to dlerror(). It returns NULL if no errors have occurred since initialization or since it was last called. dlopen() The function dlopen() loads the dynamic library file named by the null-terminated string filename and returns an opaque "handle" for the dynamic library. If filename is NULL, then the returned handle is for the main program. If filename contains a slash ("/"), then it is interpreted as a (relative or absolute) pathname. Otherwise, the dynamic linker searches for the library as follows (see ld.so(8) for further details): o (ELF only) If the executable file for the calling program contains a DT_RPATH tag, and does not contain a DT_RUNPATH tag, then the directories listed in the DT_RPATH tag are searched. o If, at the time that the program was started, the environment variable LD_LIBRARY_PATH was defined to contain a colon-separated list of directories, then these are searched. (As a security measure this variable is ignored for set-user-ID and set-group-ID programs.) o (ELF only) If the executable file for the calling program contains a DT_RUNPATH tag, then the directories listed in that tag are searched. o The cache file /etc/ld.so.cache (maintained by ldconfig(8)) is checked to see whether it contains an entry for filename. o The directories /lib and /usr/lib are searched (in that order). If the library has dependencies on other shared libraries, then these are also automatically loade