[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Questions on exporting functions from a shared library
From: |
Jef Driesen |
Subject: |
Questions on exporting functions from a shared library |
Date: |
Thu, 18 Sep 2008 14:42:11 +0200 |
User-agent: |
Thunderbird 2.0.0.16 (Windows/20080708) |
I have a cross platform (win32/unix) project that consist of a C library
and a few example applications using that library. The entire project is
build with autotools. With the instructions from the online autotools
book [1], I managed to build both a Windows DLL and a Unix shared
library. But right now, every non-static function is exported. I would
like to limit that to only the functions that are part of the public api.
It appears there are two options to do that:
1. Using dllexport/dllimport in the source code.
2. Using a DEF file during linking (with -export-symbols flag).
What are the (dis)advantages of each method? I see differences in usage
(see below), but are there technical differences as well?
The first one seems to be the most complicated method, because you need
to be able to distinguish between static/shared library builds, and
export/import in the case of a shared library.
For the second one, you need to maintain a separate list of all the
public functions. However in my case, this list is not static and can
change depending on a number of external factors that are detected in
the configure script (such as the target platform). I found a solution
for that by #ifdef's in the file and running the C preprocessor over it.
Note: It should also be possible to compile the dll with an msvc
compiler on Windows, and link a mingw32 compiled dll in an msvc
application. I don't know if that makes a difference.
[1] http://sourceware.org/autobook/autobook/autobook_251.html#SEC251
- Questions on exporting functions from a shared library,
Jef Driesen <=
- Re: Questions on exporting functions from a shared library, Brian Dessent, 2008/09/18
- Re: Questions on exporting functions from a shared library, Jef Driesen, 2008/09/18
- Re: Questions on exporting functions from a shared library, Brian Dessent, 2008/09/19
- Re: Questions on exporting functions from a shared library, Ralf Wildenhues, 2008/09/19
- Re: Questions on exporting functions from a shared library, Jef Driesen, 2008/09/22
- Re: Questions on exporting functions from a shared library, Brian Dessent, 2008/09/22
- Re: Questions on exporting functions from a shared library, Jef Driesen, 2008/09/23