public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Confused about linking
@ 2004-08-10  2:17 lrtaylor
  2004-08-10  9:00 ` Mattias Brändström
  0 siblings, 1 reply; 5+ messages in thread
From: lrtaylor @ 2004-08-10  2:17 UTC (permalink / raw)
  To: ishwar, thebrasse; +Cc: gcc-help

No, that is not right.  If you look at his file listing, he obviously does have libboost_thread installed.

-lxx causes the linker to look first for libxx.so and then libxx.a, unless you override that default by specifying the appropriate actions.  In this case, with -lboost_thread, it's going to look for libboost_thread.so and then libboost_thread.a.  However, neither of them exists - instead, you have libboost_thread.so.1.  Create a symbolic link in /usr/lib named libboost_thread.so to libboost_thread.so.1, and you should be OK.

For example, execute the following commands:

su (must be logged in as root)
cd /usr/bin
ln -s libboost_thread.so.1 libboost_thread.so

Cheers,
Lyle

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On Behalf Of Ishwar Rattan
Sent: Monday, August 09, 2004 4:51 PM
To: Mattias Brändström
Cc: gcc-help@gcc.gnu.org
Subject: Re: Confused about linking

-lxx

implies that libxx.a exists in the specified path, has nothing
to do with shared libraries. Install libboost-thread first!

-ishwar


On Mon, 9 Aug 2004, [ISO-8859-1] Mattias Brändström wrote:

> Hello!
>
> I am seriously confused when it comes to linking my executable written
> in C++. More specificaly I want to link againts boost_thread and
> boost_regex on a Fedora 2 system.
>
> These files are located in /usr/lib:
>
> /usr/lib/libboost_thread.so.1
> /usr/lib/libboost_thread.so.1.31.0
> /usr/lib/libboost_regex.a
> /usr/lib/libboost_regex.so.1.31.0
> /usr/lib/libboost_regex.so.1
>
> I have a small file named 'foo.cpp' containing the following:
>
> int main()
> {
>    return 0;
> }
>
> When I try the following:
>
> g++ foo.cpp -L/usr/lib -lboost_regex
>
> everthing works fine. But when I do this:
>
> g++ foo.cpp -L/usr/lib -lboost_thread
>
> I get:
>
> /usr/bin/ld: cannot find -lboost_thread
> collect2: ld returned 1 exit status
>
> When removing /usr/lib/libboost_regex.a I get the same error as above
> when trying to 'g++ foo.cpp -L/usr/lib -lboost_regex'.
>
> I was under the impression that g++ would look for shared librarires and
> try to link againt them first and if that didn't work try to link againt
> static libraries. Perhaps this is not tha case? Can someone enlighten me
> on this, probalbly trivial, issue?
>
> Thanks in advance!
>
> :.:: mattias
>
> PS.
>  > g++ -v foo.cpp -L/usr/lib -lboost_thread
>
> Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/specs
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --enable-shared --enable-threads=posix
> --disable-checking --disable-libunwind-exceptions --with-system-zlib
> --enable-__cxa_atexit --host=i386-redhat-linux
> Thread model: posix
> gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
>   /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/cc1plus -quiet -v
> -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D_GNU_SOURCE
> foo.cpp -D__GNUG__=3 -quiet -dumpbase foo.cpp -auxbase foo -version -o
> /tmp/cccCYtHd.s
> GNU C++ version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) (i386-redhat-linux)
>          compiled by GNU C version 3.3.3 20040412 (Red Hat Linux 3.3.3-7).
> GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64549
> ignoring nonexistent directory "/usr/i386-redhat-linux/include"
> #include "..." search starts here:
> #include <...> search starts here:
>   /usr/include/c++/3.3.3
>   /usr/include/c++/3.3.3/i386-redhat-linux
>   /usr/include/c++/3.3.3/backward
>   /usr/local/include
>   /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/include
>   /usr/include
> End of search list.
>   as -V -Qy -o /tmp/ccqqpjhi.o /tmp/cccCYtHd.s
> GNU assembler version 2.15.90.0.3 (i386-redhat-linux) using BFD version
> 2.15.90.0.3 20040415
>   /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/collect2 --eh-frame-hdr -m
> elf_i386 -dynamic-linker /lib/ld-linux.so.2
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crti.o
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/crtbegin.o -L/usr/lib
> -L/usr/lib/gcc-lib/i386-redhat-linux/3.3.3
> -L/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../.. /tmp/ccqqpjhi.o
> -lboost_thread -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/crtend.o
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crtn.o
> /usr/bin/ld: cannot find -lboost_thread
> collect2: ld returned 1 exit status
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Confused about linking
  2004-08-10  2:17 Confused about linking lrtaylor
@ 2004-08-10  9:00 ` Mattias Brändström
  0 siblings, 0 replies; 5+ messages in thread
From: Mattias Brändström @ 2004-08-10  9:00 UTC (permalink / raw)
  To: gcc-help

lrtaylor@micron.com wrote:
> -lxx causes the linker to look first for libxx.so and then libxx.a, unless you override that default by specifying the appropriate actions.  In this case, with -lboost_thread, it's going to look for libboost_thread.so and then libboost_thread.a.  However, neither of them exists - instead, you have libboost_thread.so.1.  Create a symbolic link in /usr/lib named libboost_thread.so to libboost_thread.so.1, and you should be OK.
> 
> For example, execute the following commands:
> 
> su (must be logged in as root)
> cd /usr/bin
> ln -s libboost_thread.so.1 libboost_thread.so
> 

Thanks everyone! When creating the symbolic link everything works fine! 
Now why didn't I try that in the first place? =)

:.:: mattias

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Confused about linking
  2004-08-09 16:33 Mattias Brändström
  2004-08-09 17:10 ` Eljay Love-Jensen
@ 2004-08-10  0:23 ` Ishwar Rattan
  1 sibling, 0 replies; 5+ messages in thread
From: Ishwar Rattan @ 2004-08-10  0:23 UTC (permalink / raw)
  To: Mattias Brändström; +Cc: gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=X-UNKNOWN, Size: 3575 bytes --]

-lxx

implies that libxx.a exists in the specified path, has nothing
to do with shared libraries. Install libboost-thread first!

-ishwar


On Mon, 9 Aug 2004, [ISO-8859-1] Mattias Brändström wrote:

> Hello!
>
> I am seriously confused when it comes to linking my executable written
> in C++. More specificaly I want to link againts boost_thread and
> boost_regex on a Fedora 2 system.
>
> These files are located in /usr/lib:
>
> /usr/lib/libboost_thread.so.1
> /usr/lib/libboost_thread.so.1.31.0
> /usr/lib/libboost_regex.a
> /usr/lib/libboost_regex.so.1.31.0
> /usr/lib/libboost_regex.so.1
>
> I have a small file named 'foo.cpp' containing the following:
>
> int main()
> {
>    return 0;
> }
>
> When I try the following:
>
> g++ foo.cpp -L/usr/lib -lboost_regex
>
> everthing works fine. But when I do this:
>
> g++ foo.cpp -L/usr/lib -lboost_thread
>
> I get:
>
> /usr/bin/ld: cannot find -lboost_thread
> collect2: ld returned 1 exit status
>
> When removing /usr/lib/libboost_regex.a I get the same error as above
> when trying to 'g++ foo.cpp -L/usr/lib -lboost_regex'.
>
> I was under the impression that g++ would look for shared librarires and
> try to link againt them first and if that didn't work try to link againt
> static libraries. Perhaps this is not tha case? Can someone enlighten me
> on this, probalbly trivial, issue?
>
> Thanks in advance!
>
> :.:: mattias
>
> PS.
>  > g++ -v foo.cpp -L/usr/lib -lboost_thread
>
> Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/specs
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --enable-shared --enable-threads=posix
> --disable-checking --disable-libunwind-exceptions --with-system-zlib
> --enable-__cxa_atexit --host=i386-redhat-linux
> Thread model: posix
> gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
>   /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/cc1plus -quiet -v
> -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D_GNU_SOURCE
> foo.cpp -D__GNUG__=3 -quiet -dumpbase foo.cpp -auxbase foo -version -o
> /tmp/cccCYtHd.s
> GNU C++ version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) (i386-redhat-linux)
>          compiled by GNU C version 3.3.3 20040412 (Red Hat Linux 3.3.3-7).
> GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64549
> ignoring nonexistent directory "/usr/i386-redhat-linux/include"
> #include "..." search starts here:
> #include <...> search starts here:
>   /usr/include/c++/3.3.3
>   /usr/include/c++/3.3.3/i386-redhat-linux
>   /usr/include/c++/3.3.3/backward
>   /usr/local/include
>   /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/include
>   /usr/include
> End of search list.
>   as -V -Qy -o /tmp/ccqqpjhi.o /tmp/cccCYtHd.s
> GNU assembler version 2.15.90.0.3 (i386-redhat-linux) using BFD version
> 2.15.90.0.3 20040415
>   /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/collect2 --eh-frame-hdr -m
> elf_i386 -dynamic-linker /lib/ld-linux.so.2
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crti.o
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/crtbegin.o -L/usr/lib
> -L/usr/lib/gcc-lib/i386-redhat-linux/3.3.3
> -L/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../.. /tmp/ccqqpjhi.o
> -lboost_thread -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/crtend.o
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crtn.o
> /usr/bin/ld: cannot find -lboost_thread
> collect2: ld returned 1 exit status
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Confused about linking
  2004-08-09 16:33 Mattias Brändström
@ 2004-08-09 17:10 ` Eljay Love-Jensen
  2004-08-10  0:23 ` Ishwar Rattan
  1 sibling, 0 replies; 5+ messages in thread
From: Eljay Love-Jensen @ 2004-08-09 17:10 UTC (permalink / raw)
  To: Mattias Brändström, gcc-help

Hi Mattias,

Try this...

cd /usr/lib
ln -s libboost_thread.so.1 libboost_thread.so
ln -s libboost_regex.so.1 libboost_regex.so

Then see if it links.

Otherwise, try putting in the fully qualified pathname:
g++ foo.cpp /usr/bin/libboost_regex.so.1 /usr/bin/libboost_thread.so.1

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Confused about linking
@ 2004-08-09 16:33 Mattias Brändström
  2004-08-09 17:10 ` Eljay Love-Jensen
  2004-08-10  0:23 ` Ishwar Rattan
  0 siblings, 2 replies; 5+ messages in thread
From: Mattias Brändström @ 2004-08-09 16:33 UTC (permalink / raw)
  To: gcc-help

Hello!

I am seriously confused when it comes to linking my executable written 
in C++. More specificaly I want to link againts boost_thread and 
boost_regex on a Fedora 2 system.

These files are located in /usr/lib:

/usr/lib/libboost_thread.so.1
/usr/lib/libboost_thread.so.1.31.0
/usr/lib/libboost_regex.a
/usr/lib/libboost_regex.so.1.31.0
/usr/lib/libboost_regex.so.1

I have a small file named 'foo.cpp' containing the following:

int main()
{
   return 0;
}

When I try the following:

g++ foo.cpp -L/usr/lib -lboost_regex

everthing works fine. But when I do this:

g++ foo.cpp -L/usr/lib -lboost_thread

I get:

/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status

When removing /usr/lib/libboost_regex.a I get the same error as above 
when trying to 'g++ foo.cpp -L/usr/lib -lboost_regex'.

I was under the impression that g++ would look for shared librarires and 
try to link againt them first and if that didn't work try to link againt 
static libraries. Perhaps this is not tha case? Can someone enlighten me 
on this, probalbly trivial, issue?

Thanks in advance!

:.:: mattias

PS.
 > g++ -v foo.cpp -L/usr/lib -lboost_thread

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix 
--disable-checking --disable-libunwind-exceptions --with-system-zlib 
--enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
  /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/cc1plus -quiet -v 
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D_GNU_SOURCE 
foo.cpp -D__GNUG__=3 -quiet -dumpbase foo.cpp -auxbase foo -version -o 
/tmp/cccCYtHd.s
GNU C++ version 3.3.3 20040412 (Red Hat Linux 3.3.3-7) (i386-redhat-linux)
         compiled by GNU C version 3.3.3 20040412 (Red Hat Linux 3.3.3-7).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64549
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
  /usr/include/c++/3.3.3
  /usr/include/c++/3.3.3/i386-redhat-linux
  /usr/include/c++/3.3.3/backward
  /usr/local/include
  /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/include
  /usr/include
End of search list.
  as -V -Qy -o /tmp/ccqqpjhi.o /tmp/cccCYtHd.s
GNU assembler version 2.15.90.0.3 (i386-redhat-linux) using BFD version 
2.15.90.0.3 20040415
  /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/collect2 --eh-frame-hdr -m 
elf_i386 -dynamic-linker /lib/ld-linux.so.2 
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o 
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crti.o 
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/crtbegin.o -L/usr/lib 
-L/usr/lib/gcc-lib/i386-redhat-linux/3.3.3 
-L/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../.. /tmp/ccqqpjhi.o 
-lboost_thread -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc 
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/crtend.o 
/usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crtn.o
/usr/bin/ld: cannot find -lboost_thread
collect2: ld returned 1 exit status

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-08-10  7:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-10  2:17 Confused about linking lrtaylor
2004-08-10  9:00 ` Mattias Brändström
  -- strict thread matches above, loose matches on Subject: below --
2004-08-09 16:33 Mattias Brändström
2004-08-09 17:10 ` Eljay Love-Jensen
2004-08-10  0:23 ` Ishwar Rattan

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).