How to tell the MinGW linker not to export all symbols?
Posted
by James R.
on Stack Overflow
See other posts from Stack Overflow
or by James R.
Published on 2010-05-11T11:11:43Z
Indexed on
2010/05/11
15:54 UTC
Read the original article
Hit count: 233
Hello, I'm building a Windows dynamic library using the MinGW toolchain.
To build this library I'm statically linking to other 2 which offer an API and I have a .def
file where I wrote the only symbol I want to be exported in my library.
The problem is that GCC is exporting all of the symbols including the ones from the libraries I'm linking to. Is there anyway to tell the linker just to export the symbols in the def
file?
I know there is the option --export-all-symbols
but there seems not to be the opposite to it.
Right now the last line of the build script has this structure:
g++ -shared CXXFLAGS DEFINES INCLUDES -o library.dll library.cpp DEF_FILE \
OBJECT_FILES LIBS -Wl,--enable-stdcall-fixup
EDIT: In the docs about the linker it says that --export-all-symbols
is the default behavior and that it's disabled when you don't use that option explicitly if you provide a def
file, except when it doesn't; the symbols in 3rd party libs are being exported anyway.
EDIT: Adding the option --exclude-libs LIBS
doesn't keep their symbols from being exported either.
© Stack Overflow or respective owner