This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can not link to shared libraries with LD_LIBRARY_PATH.



 ÂHi, Ian. Thanks a lot for your help.

 ÂActually, I don't have neither 'libncx.so' nor 'libagt.so', just 'libncx.so.2.2' and 'libagt.so.2.2'.
Â
 ÂThe only way to generate the executable was to include the absolute path to those files on gcc command line:

 Âgcc -Wall test2.c /usr/lib/libncx.so.2.2 /usr/lib/libagt.so.2.2

 ÂBest regards.

---------------------------------------------
HELCIO WAGNER DA SILVA


----- Mensagem original -----
De: Ian Lance Taylor <iant@google.com>
Para: Helcio Wagner <hwsilva@yahoo.com.br>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Enviadas: Sexta-feira, 22 de Junho de 2012 3:06
Assunto: Re: Can not link to shared libraries with LD_LIBRARY_PATH.

Helcio Wagner <hwsilva@yahoo.com.br> writes:

> Â ÂHi, Ian.
>
> Â ÂThat's the message received:
>
> helcio@jaguar: gcc -Wall test2.c
> test2.c: Na funÃÃo âmainâ:
> /tmp/ccab0AHD.o: In function `main':
>
> test2.c:(.text+0xa): undefined reference to `dlq_createQue'
> collect2: ld returned 1 exit status

You didn't use a -l option to tell the linker to search the library
where the symbol is defined.

E.g.,

gcc -Wall test2.c -lncx

Note that for this to work you must have libncx.so or libncx.a in
/usr/lib. libncx.so.2.2 is used at runtime, not link time. Packages on
Ubuntu are often split into runtime and development variants; make sure
you have the development package installed.

Ian

> ----- Mensagem original -----
> De: Ian Lance Taylor <iant@google.com>
> Para: Helcio Wagner <hwsilva@yahoo.com.br>
> Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
> Enviadas: Sexta-feira, 22 de Junho de 2012 2:49
> Assunto: Re: Can not link to shared libraries with LD_LIBRARY_PATH.
>
> Helcio Wagner <hwsilva@yahoo.com.br> writes:
>
>> Â ÂI am using gccÂ4.6.3 on Ubuntu 12.04.Â
>>
>> Â ÂFirst of all, I have no LD_LIBRARY_PATH environment variable set. Should I have it?
>>
>> Â ÂWell, I've edited '.bashrc' file to define LD_LIBRARY_PATH and pointed it to '/usr/lib' and '/usr/local/lib' directories:
>>
>> export LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
>
> It is not normally necessary to add these directories to
> LD_LIBRARY_PATH. See "man ldconfig".
>
>
>> Â ÂMy executable (named 'test') needs to be linked to two shared libraries to be generated: 'libncx.so.2.2' and 'libagt.so.2.2'. Both are located on '/usr/lib' directory. However, when I type 'gcc -Wall test2.c', there is a message relating undefined references. The executable was not generated.
>
> A problem at link time is most likely not due to LD_LIBRARY_PATH.
>
> When reporting an error message, please cut and paste the exact,
> complete, error output. Otherwise we don't know what happened.
>
> Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]