* shared library not found while linking C program
@ 2002-08-16 8:46 pinafl
2002-08-16 8:49 ` Paul Jarc
0 siblings, 1 reply; 3+ messages in thread
From: pinafl @ 2002-08-16 8:46 UTC (permalink / raw)
To: gcc-help
hello,
i ever get that error while trying to build a C code program, calling a C-
function strored in my own shared library.
the message is:
toto.o: In function `main':
toto.o(.text+0x7): undefined reference to `function_name'
collect2: ld returned 1 exit status
GCC is called with the -L option for additionnal directory to search in.
I'd like to use the -l option to name the right library but it is not
recognised, GCC is then looking for a "-llibname" file and of course does
not find it.
Is there a particular way to create my library?
I'm working on ggc version 2.96, Red Hat Linux 7.1 2.96-98)
Any answer welcome, thanks for your help.
Florent Pinault.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: shared library not found while linking C program
2002-08-16 8:46 shared library not found while linking C program pinafl
@ 2002-08-16 8:49 ` Paul Jarc
0 siblings, 0 replies; 3+ messages in thread
From: Paul Jarc @ 2002-08-16 8:49 UTC (permalink / raw)
To: pinafl; +Cc: gcc-help
<pinafl@freesurf.fr> wrote:
> GCC is called with the -L option for additionnal directory to search in.
> I'd like to use the -l option to name the right library but it is not
> recognised, GCC is then looking for a "-llibname" file and of course does
> not find it.
gcc ... /path/to/libfoo.so
is equivalent to:
gcc ... -L/path/to -lfoo.so
So use the first form if your library is not named lib*. You'll
probably also want to add /path/to to $LD_RUN_PATH at compile time or
$LD_LIBRARY_PATH at run time, if the library isn't in one of the
system library directories.
paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: shared library not found while linking C program
[not found] <57870.194.2.91.222.1029512777.squirrel@arlette.freesurf.fr >
@ 2002-08-16 9:28 ` Eljay Love-Jensen
0 siblings, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2002-08-16 9:28 UTC (permalink / raw)
To: pinafl, gcc-help
COMPILE:
gcc toto.o myOwnSharedLibrary.so -o toto.executable
(Always put the files WITH the dependency first, and the files that PROVIDE
the linkage later in the link line. Probably not necessary for .so files,
but a good habit to get into.)
RUN:
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH toto.exectuable
I assume you don't have . (current working directory) in your LD_LIBRARY_PATH.
--Eljay
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-08-16 16:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-16 8:46 shared library not found while linking C program pinafl
2002-08-16 8:49 ` Paul Jarc
[not found] <57870.194.2.91.222.1029512777.squirrel@arlette.freesurf.fr >
2002-08-16 9:28 ` Eljay Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).