Specifying the DEF file when compiling a DLL with Clang

a 夏天 提交于 2020-06-17 09:39:27

问题


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 -

  1. We can use the -Wl flag in clang to pass some comma-separated arguments to the linker.
  2. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!