问题
I am trying to compile a DLL using clang in windows
clang -shared structs.c -o structs.dll
but the symbols aren't being exported..
If I add __declspec(dllexport) to my declarations in structs.h, They symbols are exported to DLL.
But instead, I would like to do this using a DEF file (structs.def) I created, But I can't find how I pass the DEF file to clang.
Any help is appeciated :/
回答1:
Finally figured it out -
- We can use the -Wl flag in clang to pass some comma-separated arguments to the linker.
- DEF files can be specified using /DEF argument
Example
clang -shared structs.c -o structs.dll -Wl"/DEF:structs.def"
来源:https://stackoverflow.com/questions/62358124/specifying-the-def-file-when-compiling-a-dll-with-clang