問題描述
使用 VS2005,我想創建一個 DLL 并自動導出所有符號,而無需在任何地方添加 __declspec(dllexport) 并且無需手動創建 .def 文件.有沒有辦法做到這一點?
With VS2005, I want to create a DLL and automatically export all symbols without adding __declspec(dllexport) everywhere and without hand-creating .def files. Is threre a way to do this?
推薦答案
可以做到...
我們在這里的做法是使用鏈接器的/DEF 選項來傳遞一個 "模塊定義文件" 包含我們的導出列表.我從您的問題中了解到您了解這些文件.但是,我們不是手工完成的.導出列表本身由 dumpbin/LINKERMEMBER 命令創建,并且通過一個簡單的腳本將輸出處理為模塊定義文件的格式.
The way we do it here is to use the /DEF option of the linker to pass a "module definition file" containing a list of our exports. I see from your question that you know about these files. However, we do not do it by hand. The list of exports itself is created by the dumpbin /LINKERMEMBER command, and manipulating the output via a simple script to the format of a module definition file.
設置工作量很大,但它允許我們編譯在 Windows 上為 Unix 創建的沒有 dllexport 聲明的代碼.
It is a lot of work to setup, but it allows us to compile code created without dllexport declarations for Unix on Windows.
這篇關于創建 DLL 時導出所有符號的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!