This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Gcc static linking problems
- From: "Tim Purkerson" <timp at apcon dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Mon, 11 Aug 2003 14:25:52 -0700
- Subject: Gcc static linking problems
This is multi-part question that I have been struggling with for the
past few days. I know similar issues have been addressed recently, but
they haven't worked for me.
My company had developed an application on a previous version of Solaris
(probably 2.7) and built it statically. Well, a few years have passed
and we are looking to make some changes on it. This time, however, it is
on Solaris 9 and currently using gcc 3.2.1.
If I use the exact source code and makefile everything works great
except it builds the application to use dynamic linking. This becomes a
problem when our customer's systems don't have the libraries this
application needs (libstdc++ specifically).
So, the obvious solution is to build it statically, but I can't get it
to build. There are error messages about unresolved externals that
should be resolved in the libsocket library.
Here are the questions:
1. Is there any reason why we shouldn't be trying to build it
statically? How could we make sure our customers have the necessary
libraries if we do build it dynamically?
2. I have seen a lot of posts about adding -static to the build line and
even alternating static and dynamic to get it to build correctly. I have
tried many combination of this with no success. What am I doing wrong on
this line?
g++ -lnsl -lsocket program.o -o program -static -lstdc++
3. Is this problem caused by gcc or by Solaris or by the user?
Any thoughts would be appreciated.
Thanks,
Tim