gcc vs. g++ for linking with --as-needed.

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

 



Hello.

I've managed to resolve compilation problems with
LDFLAGS="-Wl,--as-needed" in gigabase [1] package but before I'll report
upstream I'd like to ensure that my fix is correct.

Without --as-needed everything compiles and works fine. Before fix
compilation stopped on error:

./libtool --mode=link i686-pc-linux-gnu-g++ -Wl,--as-needed -pthread  -o guess guess.o libgigabase_r.la
i686-pc-linux-gnu-g++ -Wl,--as-needed -pthread -o .libs/guess guess.o  ./.libs/libgigabase_r.so -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2 -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../.. -lstdc++ -lm -lgcc_s -lc -lgcc_s
./.libs/libgigabase_r.so: undefined reference to `pthread_create'

Currently I fixed the problem by changing g++ to gcc
(i686-pc-linux-gnu-g++ > i686-pc-linux-gnu-gcc) or more rigorously I've
changed "LD = $(CXX)"  with "LD = $(CC)" in Makefile.in (package without
automake). But two questions still remains I'm unsure with the answers
on them:

1. Did I understood correctly that the only right way to link is to call
gcc instead of g++? In google I found page which states the opposite
[2], so I'm really confused.

2. Shall I put -pthread after all objects (after libgigase_r.la) or gcc
takes care about -lpthread position by itself? This question arose as at
the beginning I've tried to fix the problem by changing linking order
and putting -pthread at the end and although this does not fix the
problem I'm curious does there exit "right" order for -pthread?

References,
[1] http://www.garret.ru/~knizhnik/gigabase.html
[2] http://www.cs.washington.edu/orgs/acm/tutorials/dev-in-unix/compiler.html

Thank you very much in advance,
-- 
Peter.

Attachment: signature.asc
Description: =?UTF-8?Q?=D0=AD=D1=82=D0=B0?= =?UTF-8?Q?_=D1=87=D0=B0=D1=81=D1=82=D1=8C?= =?UTF-8?Q?_=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?Q?_=D0=BF=D0=BE=D0=B4=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B0?= =?UTF-8?Q?_=D1=86=D0=B8=D1=84=D1=80=D0=BE=D0=B2=D0=BE=D0=B9?= =?UTF-8?Q?_=D0=BF=D0=BE=D0=B4=D0=BF=D0=B8=D1=81=D1=8C=D1=8E?=


[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