24,855
社区成员
发帖
与我相关
我的任务
分享
#ifdef LOAD_DEF
#define DLLTEST_API
#pragma comment (linker, "/DEF:\"../Library/DLLTest.def\"") // 给链接器指定DEF文件,以改变导出函数名
#else
#define DLLTEST_API __declspec(dllexport) // 不改变导出函数名
#endif
// 以下是导出函数声明
DLLTEST_API void fn1 (xxxxx);
#pragma comment( comment-type [,"commentstring"] )
linker
Places a linker option in the object file. You can use this comment-type to specify a linker option instead of passing it to the command line or specifying it in the development environment. For example, you can specify the /include option to force the inclusion of a symbol:
#pragma comment(linker, "/include:__mySymbol")
Only the following ( comment-type) linker options are available to be passed to the linker identifier:
/DEFAULTLIB
/EXPORT
/INCLUDE
/MANIFESTDEPENDENCY
/MERGE
/SECTION
里面似乎没有/DEF选项供用户自定义,而我不想通过IDE来设置def文件的具体加载信息,即,我想让代码除了makefile以外的部分,不再依赖开发环境。
2. vs 2010的log显示的就是:
DLLTest.obj : warning LNK4229: invalid directive '/DEF:../Library/DLLTest.def' encountered; ignored
因而,用denpency查看该dll发现,由于没有引入def文件,该dll没有导出任何接口函数。
3. VC6一切正常。