Re: symbol lookup error: undefined symbol

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey German,

one further question. Doesn't your library show up in ldd output anyway
or does it show up the following?

andi@roma:~/Programming/c++$ ldd main
    linux-gate.so.1 =>  (0xb80e3000)
    libmy.so => not found
    libmy2.so => not found
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7fc6000)
    libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7fa0000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7f91000)
    libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e33000)
    /lib/ld-linux.so.2 (0xb80c9000)

If it appears as "not found", you need to set the environment variable
LD_LIBRARY_PATH to e.g. "." or whatever
directory your library is located in.

Best regards,
Andi

Andi Hellmund wrote:
> Hey German,
>
> yes, it should be listed with ldd.
>
> You could add -Wl,-y,<any_of_your_symbols>, e.g.
> -Wl,-y,_ZN3ftr10Aplicacion11dibujarTodoER9SDL_Event
> and check the output, if the linker searches your library.
>
> A sample output could look like:
>
> andi@roma:~/Programming/c++$ g++ main.o -Wl,-y,_ZdaPv -o main
> main.o: reference to operator delete[](void*)
> /usr/lib/gcc/i486-linux-gnu/4.3.2/libstdc++.so: definition of operator
> delete[](void*)
>
> I hope that helps to at least further narrow the problem, if still present.
>
> Best regards,
> Andi
>
> Germán Diago wrote:
>   
>> I noticed now that using ldd does not list libmylib as a dependency of
>> the executable. I think it should, shouldn't it?
>>
>>
>> 2009/4/11 Germán Diago <germandiago@xxxxxxxxx>:
>>   
>>     
>>> Hello. I'm having problems with what it seemed to work before. I'm
>>> under ubuntu 9.04, gcc .4.3.3 compiler.
>>>
>>> I have a project in which I build a shared library.
>>> The shared library is later used  in an executable.
>>>
>>> When I try to run the executable, once compiled, I get a strange error:
>>>
>>> It does not find some symbols from my shared library. I checked the
>>> library with the program nm.
>>> There are no undefined (relevant) symbols for my shared library there.
>>>
>>> However, in my executable, the following is shown with nm -u (I just
>>> copy here what it's relevant):
>>>
>>>         U _ZN3ftr10Aplicacion11dibujarTodoER9SDL_Event
>>>         U _ZN3ftr10Aplicacion11inicializarEv
>>>         U _ZN3ftr10Aplicacion12addDibujableERKN5boost8functionIFvR9SDL_EventESaIvEEENS_15PrioridadDibujoE
>>>         U _ZN3ftr10Aplicacion17refrescarPantallaEv
>>>         U _ZN3ftr10Aplicacion8addTareaEPFvR9SDL_EventE
>>>         U _ZN3ftr10Aplicacion8ejecutarEv
>>>         U _ZN3ftr10AplicacionD1Ev
>>>         U _ZN3ftr12MonitorDatos7dibujarER9SDL_Event
>>>         U _ZN3ftr12MonitorDatosC1Ev
>>>         U _ZN3ftr12MonitorDatosD1Ev
>>>         U _ZN3ftr18ParseadorEscenario7parsearERKSs
>>>         U _ZN3ftr18ParseadorEscenarioC1ERNS_9EscenarioE
>>>         U _ZN3ftr18ParseadorEscenarioD1Ev
>>>         U _ZN3ftr18ParseadorPersonaje7parsearERKSs
>>>         U _ZN3ftr18ParseadorPersonajeC1ERNS_9PersonajeE
>>>         U _ZN3ftr18ParseadorPersonajeD1Ev
>>>         U _ZN3ftr9Escenario11inicializarEv
>>>         U _ZN3ftr9Escenario7dibujarER9SDL_Event
>>>         U _ZN3ftr9EscenarioC1Ev
>>>         U _ZN3ftr9EscenarioD1Ev
>>>         U _ZNK3ftr9Personaje7getPosXEv
>>>         U _ZNK3ftr9Personaje7getPosYEv
>>>
>>>
>>> These symbols are from the library I compiled, and they appear as
>>> undefined in the executable, so when I try to execute
>>> my program, it fails.
>>>
>>> If I compile a Static library everything is ok, but I need to compile
>>> a shared library for other purposes.
>>>
>>>
>>> This compilation command is used to build files in my shared library:
>>>
>>>  g++ -o build/linux2/release/libmylib/Utility.os -c -O3 -fPIC
>>> -D_GNU_SOURCE=1 -D_REENTRANT -DDATA_DIR=\"/usr/share/mylib/\"
>>> -DTIXML_USE_STL=YES -I/usr/include/python2.6 -I/usr/include/SDL
>>> -Ibuild/linux2/release/libmylib -Ilibmylib -Itinyxml
>>> libfollowtherabbit/Utility.cpp
>>>
>>> This is the link gcc command:
>>>
>>> g++ -o build/linux2/release/libmylib/libmylib.so -shared (all object
>>> files here and other libraries here)
>>>
>>> This is used for my executable:
>>>
>>>  g++ -o build/linux2/release/src/myprogram
>>> build/linux2/release/src/myprogram.o -Lbuild/linux2/release/libmylib
>>> -Llibmylib -L/usr/lib -lmylib
>>> build/linux2/release/tinyxml/libtinyxml.a -lSDL_ttf -lSDL_mixer -lSDL
>>>
>>> Thanks for your help
>>>
>>>     
>>>       
>>   
>>     
>
>
>   


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux