This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Linking a shared library into libbackend.a?
- From: Guy Montag <theguymontag at yahoo dot com>
- To: Guy Montag <theguymontag at yahoo dot com>, gcc at gcc dot gnu dot org
- Date: Sat, 31 Aug 2002 21:43:53 -0700 (PDT)
- Subject: Re: Linking a shared library into libbackend.a?
--- Guy Montag <theguymontag@yahoo.com> wrote:
> I have written a hook directly into
> rest_of_compilation in toplev.o. I would like this
> hook to be present for the entire compiler proper. I
> understand perfectly well how to add in an unlinked
> object file, under “EXTRA_OBJS.” The challenge is
> that
> the hook is written in C++. I have to compile and
> link
> the object file with libstdc++, creating libhook.so.
> When I add in this file into EXTRA_OBJS, the
> compiler
> complains:
>
> ./cc1: relocation error: ./cc1: undefined symbol:
> hook
>
> I am afraid that I do not yet have the knowledge to
> identify why the shared library isn't working. I
> also
> do not know where I might add in the flags “.L/.
> -lhook” to directly tell GCC what to do.
>
> Any help would be GREATLY appreciated!!!
>
> -Guy
>
> hook.h
> int hook(void);
>
> hook.cpp
> #include <iostream>
> extern "C" int hook() {...}
>
> gcc -fpic -c hook.cpp
> gcc -shared -o libhook.so hook.o -lstdc++
>
Problem solved. The LIBS variable appears to be well
situated to add in a .lhook flag to compile in the
shared library. I recompiled G++ with the change and
it works.
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com