I attempted to build a win32 static library using the i686-w64-mingw32
cross-build toolchain.
I built the object files and the mylib.lib
file via a Makefile:
$(program_RELEASE_NAME_WIN_STATIC): $(RELEASE_OBJS_WIN32_STATIC)
i686-w64-mingw32-gcc-ar rcs $(BUILD_DIR_WIN32)/static/$@ $^
$(BUILD_DIR_WIN32)/static/%.o: %.c $(HEADERS)
$(RELEASE_LINK_WIN32.c) $< -c -o $@
This gave me the static library mylib.lib
. Inspecting this on the linux side with nm
I can see all the constituent object files and the functions they contain
No when I inspect mylib.lib
on a windows 10 VM, i.e.
DUMPBIN /EXPORTS mylib.lib
I get:
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file mylib.lib
File Type: LIBRARY
Summary
C .bss
C .data
6AC .drectve
5EAC .rdata
444 .rdata$zzz
29900 .text
38 .text.unlikely
None of the functions are being exported.
In the relevant header file I mark up the functions I want to export with __declspec(dllexport)
This worked fine when I was producing a .dll, i.e. the functions I marked for export were the only ones that were visible in the .dll file
But for the static library equivalent nothing is being exported?
How are you meant to make functions visible in a win32 .lib file?