I need to use some symbols from the main executable in a plugin.
Linking against the executable causes the following linker errors:
i686-w64-mingw32-g++
Like Keith Marshall stated in the comments, -Wl,--out-implib indeed works in combination with either:
-Wl,--export-all-symbols
by declaring symbols with __declspec(dllexport)
or by providing a .def file
I went with the third option and wrote a bash script to generate a def file / version scripts on-the-fly to avoid exporting a lot of unneeded symbols.
The script can be found here.
Use it like:
export SYMBOLS_TO_EXPORT="*tools* *network* _Z8compressPvRjPKvjib ..." # use mangled names and skip leading underscores on i686
export HOSTPREFIX=i686-w64-mingw32 # unneeded on Windows
i686-w64-mingw32-g++ $(OBJS) `./gen_export_file $(OBJS)` -Wl,--out-implib=foo.exe.a -o foo.exe