I'm statically linking libstdc++ on a SunOS 5.8 to solve compatibility
issues:
g++ foo foo.o bar.o -static -lstdc++ -dynamic -lm -lpthread
But it complains:
/usr/local/bin/ld: cannot find -lpthread
collect2: ld returned 1 exit status
I tried with -L, LD_LIBRARY_PATH, neither worked. I then tried to link
directly with /usr/lib/libpthread.so rather than putting it after -l, it did
compile fine, but when I ran foo, pthread_create() returned -1, which never
happen back in the dynamic-linking days.
So I'm stuck. Any insight?
Thanks much!
Tina
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Try:
g++ -o foo foo .o bar.o -Wl,-Bstatic lstdc++ -Wl,-Bdynamic -lm -pthread
Using the -static option directly with g++ means `don't link with
dynamic libraries'; what you need is to send the option to the linker.
(I don't have a Sun box to test this on, but it should at least be
close. ;-). If you have a problem, add `-v' to see exactly what the
invocation of ld is doing.)
>
> But it complains:
>
> /usr/local/bin/ld: cannot find -lpthread
> collect2: ld returned 1 exit status
>
> I tried with -L, LD_LIBRARY_PATH, neither worked. I then tried to link
> directly with /usr/lib/libpthread.so rather than putting it after -l, it did
> compile fine, but when I ran foo, pthread_create() returned -1, which never
> happen back in the dynamic-linking days.
>
HTH,
--ag
>
>
>
>
>
>
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
--
Artie Gold -- Austin, Texas
Thanks for the help. But I thought having -dynamic would specify those I
want as dynamically linked. Anyway, I tried with
-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lpthread
however it didn't work (most relevant output with -v on):
-Bstatic -lstdc++ -Bdynamic -lpthread -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s
-lgcc /usr/local/lib/gcc-lib/sparc-sunsolaris2.8/3.0.3/crtend.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/crt.o
And ldd still shows libstdc++.so.3 being linked. Looks like libstdc++ is
"pre-coded" to be dynamically linked?
(full output is like this:
"Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/specs
Configured with:
../configure --with-as=/usr/local/bin/as --with-ld=/usr/local/bin/ld --enabl
e-libgcj
Thread model: posix
gcc version 3.0.3
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/collect2 -V -R/usr/local/l
ib -Y P,/usr/ccs/lib:/usr/lib -Qy -o bThread_smp
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/crt1.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/crti.o
/usr/ccs/lib/values-Xa.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/crtbegin.o -L/home/thli/ro
ot/misc//RAPTOR/osllib/lib -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0
.3 -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/../../..
/../sparc-sun-solaris2.8/lib -L/usr/ccs/bin -L/usr/ccs/lib -L/usr/local/lib/
gcc-lib/sparc-sun-solaris2.8/3.0.3/../../.. foo.o
bar.o -Bstatic -lstdc++ -Bdynamic -lpthre
d -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/local/lib/gcc-lib/sparc-sunsolaris2.8/3.0.3/crtend.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/crt.o")
If I switch the order of "-Bstatic -lstdc++" and "-Bdynamic -lpthread":
-Bdynamic -Bstatic -lstdc++ -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/crtend.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/crtn.o
/usr/local/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
Is there some configuration I need to tweak, some path I need to append,
etc. etc., to have -lstdc++ out of the -dynamic list?
Thanks again!
Tina, (distraught)
"Artie Gold" <arti...@austin.rr.com> wrote in message
news:3F413D5E...@austin.rr.com...
> Thanks for the help. But I thought having -dynamic would specify those I
If you want to pass '-dynamic' to the linker, you must preceed
it with '-Wl,' -- otherwise, '-d' is interpreted by g++.
> Anyway, I tried with
>
> -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -lpthread
>
> however it didn't work (most relevant output with -v on):
Read this entire thread (there were several iterations) for a
working solution:
http://www.google.com/groups?threadm=dd7a565c.0306190732.5ecb0bd4%40posting.google.com
Cheers,
--
In order to understand recursion you must first understand recursion.
Thanks again!
Tina
"Paul Pluzhnikov" <ppluz...@earthlink.net> wrote in message
news:u7k59v3l...@earthlink.net...
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----