dlerror(): undefined symbol

Jan Vicherek jvichere@undergrad.math.uwaterloo.ca
Sat Dec 11 10:12:00 GMT 1999


 Hi,

 I'm getting :
dlerror(): ./DummyPlugin.so: undefined symbol: DbgBuf

   the whole point may be that it is impossible to use a global
symbol ``char DbgBuf[8192];'' from a loadable module. I don't
know.

   I can't seem to be able to dlopen( a shared object ); in
the main executable. The shared object is ./DummyPlugin.so and
the main executable is ./pm .


 in pm.c I have :

if ( ! dlopen ("./DummyPlugin.so", RTLD_NOW|RTLD_GLOBAL) )
        printf("dlerror(): %s", dlerror());

 and it gives me :

dlerror(): ./DummyPlugin.so: undefined symbol: DbgBuf

  DbgBuf is a global var in file Debug.cpp:

char DbgBuf[8192];
void Debug::Log(...){...}

   and in Debug.h I have :
class Debug { void Log(int, char *, int, char *, int); }
extern Debug dbg;
extern char DbgBuf[8192];

in DummyPlugin.cpp I use it this way :
#include "Debug.h"
extern "C" void test()
{
{int dbglvl=  7  ; snprintf(DbgBuf, sizeof(DbgBuf),   " " );
dbg.Log(dbglvl, "DummyPlugin.cpp", __LINE__, __PRETTY_FUNCTION__, 0);} ;
}

   Help !

  Any insight is appreciated (plz cc:jvicherek@uwaterloo.ca)

      Thanx,

               Jan

PS : if I replace the guts of the function test() with
{ printf ("Ahoyyas\n") ; }, things work.

Details follow :

422 [2] $ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

424 [2] $ cat /etc/redhat-release
Red Hat Linux release 6.1 (Cartman)

427 [2] $ rpm -qa | g egc
compat-egcs-5.2-1.0.3a.1
compat-egcs-c++-5.2-1.0.3a.1
compat-egcs-g77-5.2-1.0.3a.1
compat-egcs-objc-5.2-1.0.3a.1
egcs-1.1.2-24
egcs-c++-1.1.2-24
egcs-objc-1.1.2-24

429 [2] $ rpm -q glibc
glibc-2.1.2-11

438 [2] $ make clean
rm -f *.o pm core .depend

439 [2] $ make pm
g++ -Wall -rdynamic -g -ggdb -DLINUX  pm.cpp -c
...
g++ -Wall -rdynamic -g -ggdb -DLINUX  Debug.cpp -c
...
g++  pm.o ... Debug.o ... -lgdbm -ldl -o pm

452 [2] $ make DummyPlugin.so
g++ -Wall -rdynamic -g -ggdb -DLINUX  DummyPlugin.cpp -c
g++ -shared DummyPlugin.o -o DummyPlugin.so

453 [2] $ ./pm
dlerror(): ./DummyPlugin.so: undefined symbol: DbgBuf

459 [2] $ nm DummyPlugin.so | grep U
         U DbgBuf
         U Log__5DebugiPCclT2Pv
         U ___brk_addr@@GLIBC_2.0
         U __curbrk@@GLIBC_2.0
         U __deregister_frame_info
         U __environ@@GLIBC_2.0
         U __gmon_start__
         U __register_frame_info
         U __throw
         U atexit@@GLIBC_2.0
         U dbg
         U snprintf@@GLIBC_2.0

470 [2] $ nm pm | egrep 'DbgBuf|Log__5DebugiPCclT2Pv|dbg'
08069ea0 B DbgBuf
0804e6c8 T Log__5DebugiPCclT2Pv
0806bfa0 B dbg






More information about the Gcc-help mailing list