This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__((constructor)), shared object files and C++...
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: "Pearson, Scott" <scott dot pearson at intel dot com>
- Cc: 'Muthukumar Ratty' <muthu at iqmail dot net>,"'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>,"'gcc-help at gcc dot gnu dot org'" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 8 May 2003 13:53:01 -0400
- Subject: Re: __attribute__((constructor)), shared object files and C++...
- References: <D9223EB959A5D511A98F00508B68C20C200D2F2C@orsmsx108.jf.intel.com>
On Thu, May 08, 2003 at 10:38:48AM -0700, Pearson, Scott wrote:
> For the C++ case, I ended up with the (somewhat similar) sequence:
>
>
>
> g++ -fPIC -c libctest.cpp
>
> g++ -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0
> libctest.o
>
> ldconfig -v -n .
>
> ln -sf libctest.so.1 libctest.so
>
> g++ -o ctest -L. -lctest -lstdc++ ctest.cpp
>
>
>
> This didn't work; the module constructors/destructors were not executed.
> Where did I go wrong?
Sorry, nothing obvious jumps out at me. You don't need the -lstdc++ in
the last line though. g++ will take care of it.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer