This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How to export functions from a static library linked to an executable ?
- From: Nicolas ANTONIAZZI <nicolas dot antoniazzi at gmail dot com>
- To: GCC Help <gcc-help at gcc dot gnu dot org>
- Date: Sun, 17 Apr 2005 04:22:49 +0200
- Subject: How to export functions from a static library linked to an executable ?
- Reply-to: Nicolas ANTONIAZZI <nicolas dot antoniazzi at gmail dot com>
Hi,
I have looked for informations about dynamic libraries on internet and
man page. It helped me a lot to have more comprhensions about how
dynamic libraries are managed on linux and windows but I have
questions that didn't found answers.
Currently I'm doing my tests on linux. I compiled an executable
program A that hold a function A() and main() function.
This program load a dynamic library (B.so), get the function B() from
it and execute it.
This works fine.
Now, the function B() need to call the function A() from the main
program. It didn't worked until I have found fhe -rdynamic option
(same as -Wl,--export-dynamic) when linking the main program A.
So, everything were find here too.
But now, I want to put the function A() in a static library. this
static library is linked to the main program.
With this system, B.so will not be able to call A() from the main
program. Although I set -rdynamic when linking, the function A() is
not exported with the main program.
A() will only be exported if it is used at least one time by the main program.
So, I would like to know if someone here knows why it works like this,
and how I could say to export A() when building my main program ?
Thanks for you help.
Nicolas.