public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* to build an so containing libgcc.so and libstdc++.so
@ 2003-08-29 11:08 Ashay Shende
  2003-08-29 12:00 ` Eljay Love-Jensen
  0 siblings, 1 reply; 4+ messages in thread
From: Ashay Shende @ 2003-08-29 11:08 UTC (permalink / raw)
  To: gcc-help

Hi,
I am building an application where the final executable has dependencies on
the libgcc_s.so.1 and libstdc++.so.5 files(apart from another application
shared object)
However, these two so files are not there on the target m/c.

What I want to do is build a shared object(libtest2.so:see below) which
contains the above mentioned shared objects so that the final executable
(testfinal2.out:see below) does not have dependencies on libgcc_s.so.1 and
libstdc++.so.5 files and resulatantly these two .so files need not be
present at run-time.
(I am quite new to all this)


Here's what I did:
(I have libgcc_s.so.1 and libstdc++.so.5 in my directory and I am taking it
from there and not from usr/local/lib)

1.I created libtest2.so(from test.o) by the following command:
g++3 -shared -fPIC -h libtest2.so -o ./libtest2.so -L.
./test.o -lstdc++ -lgcc_s

2. I created testfinal2.out as follows:
g++3 -o testfinal2.out -I. -L. -Xlinker -R. -ltest2 main.cpp

The dependencies are as follows:
$ ldd testfinal2.out
        libtest2.so =>   ./libtest2.so
        libstdc++.so.5 =>        ./libstdc++.so.5
        libm.so.1 =>     /usr/lib/libm.so.1
        libgcc_s.so.1 =>         ./libgcc_s.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        /usr/platform/SUNW,Sun-Fire/lib/libc_psr.so.1

$ ldd libtest2.so
        libstdc++.so.5 =>        (file not found)
        libgcc_s.so.1 =>         (file not found)
        libm.so.1 =>     /usr/lib/libm.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        /usr/platform/SUNW,Sun-Fire/lib/libc_psr.so.1

As you can see, testfinal2.out still has dependencies on libgcc and
libstdc++ .so files.

where am I going wrong ??

Can someone tell me in detail how to build libtest2.so to include
libgcc_s.so.1 and libstdc++.so.5 so that these two files need not be present
at run-time ?

Thanks,
ashay

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

* Re: to build an so containing libgcc.so and libstdc++.so
  2003-08-29 11:08 to build an so containing libgcc.so and libstdc++.so Ashay Shende
@ 2003-08-29 12:00 ` Eljay Love-Jensen
  0 siblings, 0 replies; 4+ messages in thread
From: Eljay Love-Jensen @ 2003-08-29 12:00 UTC (permalink / raw)
  To: ashende, gcc-help

Hi Ashay,

Try linking against the static versions of those libraries.  For instance,
g++ foo.cpp -static

HTH,
--Eljay


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

* RE: to build an so containing libgcc.so and libstdc++.so
  2003-08-29 12:19 Venkatakrishnan, V
@ 2003-08-29 13:42 ` Eljay Love-Jensen
  0 siblings, 0 replies; 4+ messages in thread
From: Eljay Love-Jensen @ 2003-08-29 13:42 UTC (permalink / raw)
  To: Venkatakrishnan, V, ashende, gcc-help

Hi Venkatakrishnan,

>Any guesses why???

Link order is my guess.

Try to make sure that things are stacked in the order of dependency, with the least dependent last.

Assuming that myLib1 depends on things in myLib2, and they depend on things in stdc++, m and c:
g++ -Wl,-nostdlib -L/user/local/lib -Wl,-dy -lmyLib1 -Wl,-dn -lmyLib2 -Wl,-dy -lstdc++ -Wl,-dn -lm -lc -o myApp

The -Wl,-nostdlib is for when you are explicitly listing out the standard libraries.

The -Wl,-dy is to link against dynamic libraries (.so, .dylib, .library, .shlib, .dll ... depending on OS).

The -Wl,-dn is to link against static libraries.

If you run across an undefined symbol, look at the file where you expected it to be and see if it is there.  You can use the 'nm' or 'objdump' commands to display tons of good information about object and library files.

HTH,
--Eljay


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

* RE: to build an so containing libgcc.so and libstdc++.so
@ 2003-08-29 12:19 Venkatakrishnan, V
  2003-08-29 13:42 ` Eljay Love-Jensen
  0 siblings, 1 reply; 4+ messages in thread
From: Venkatakrishnan, V @ 2003-08-29 12:19 UTC (permalink / raw)
  To: 'Eljay Love-Jensen', ashende, gcc-help

Hi Eljay,
	Linking using -static leads to errors. coz. it then reports all
other symbols being linked in some other custom libs to be undefined.
	For example
	g++ -L/usr/local/lib -lmyLib1 -lmyLib2 -o myApp
	worked fine but
	g++ -L/usr/local/lib -lmyLib1 -lmyLib2 -static -lstdc++ -o myApp
	reports
	ld: 0711-317 ERROR: Undefined symbol: mysymbol1
	ld: 0711-317 ERROR: Undefined symbol: mysymbol2
	ld: 0711-317 ERROR: Undefined symbol: mysymbol3 etc.....

Any guesses why???

-----Original Message-----
From: Eljay Love-Jensen [mailto:eljay@adobe.com]
Sent: Friday, August 29, 2003 5:30 PM
To: ashende@cisco.com; gcc-help@gcc.gnu.org
Subject: Re: to build an so containing libgcc.so and libstdc++.so


Hi Ashay,

Try linking against the static versions of those libraries.  For instance,
g++ foo.cpp -static

HTH,
--Eljay

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

end of thread, other threads:[~2003-08-29 13:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-29 11:08 to build an so containing libgcc.so and libstdc++.so Ashay Shende
2003-08-29 12:00 ` Eljay Love-Jensen
2003-08-29 12:19 Venkatakrishnan, V
2003-08-29 13:42 ` 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).