This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Static libstdc++ and link problems
- From: Frederic RISS <frederic dot riss at st dot com>
- To: chris at tti-telecom dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: 20 Jun 2003 10:07:16 +0200
- Subject: Re: Static libstdc++ and link problems
- Organization: STMicroelectronics - DAIS - FlexWare
- References: <20030620004242.GA29897@lin-chris.tti-telecom.com>
Hi,
On Fri, 2003-06-20 at 02:42, chris@tti-telecom.com wrote:
> > I'm running a Solaris 8 box with gcc 3.2.2 and using GNU binutils. What
> > I want to do is quite simple : I've a lib written in C++ and which
> > exposes a C API. I would like the lib to only depend on the libc and not
> > on libstdc++ ; so I try to link my solib with the static libstdc++.a.
> >
> > First, is this a totally dumb idea ?
>
> No.. I've tried it too. I'ts tempting to have access to the benefits of
> C++, and creating a library that 'just works', with no special
> requirements at runtime.
>
> Unfortunatley, I suspect that it isn't *supposed* to work properly.
>
> For one, libstdc++.a is normally composed of non relocatable object
> files (no -fPIC at compile time), and you're not supposed to put those
> into your shared library. maybe this can be cured by recompiling
> libstdc++ with your own CXXFLAGS. but I this hints that it's not the
> most common thing to do...
Yes, I'm aware of that, but the fact is that the guys who asked me how
to do that with gcc3.2 were doing it with gcc 2.95.x and it simply
worked. The other thing I find strange is the error that the linker
outputs : 'undefined versionned symbol name
std::time_get_c@@GLIBCPP3.2'. I expected nearly any behaviour (runtime
relocation error, crash, ...) but not a link error. The symbol names
don't change between a static or dynamic lib.
> For the record -- putting libstdc++.a into an executable worked for me.
> The obvious g++ -static hw.cc didn't work. I needed to use
> gcc hw.cc -Wl,-B,static -lstdc++
Yes, works (and has always worked) for me too. That's weird ; how can it
be that the symbol is defined here...
Anyway, what I'm looking for is more an explanation that a solution. I
could understand that it can't work for X or Y reasons, but for the
moment I can't understand the link error and that gets me nuts. If
anybody has an idea, a pointer or a better place to ask for, I'd be
really grateful.
Regards,
Fred