开发者

Forcing an export name for Visual Studio C++ static library

I have trouble linking a static library that is made out of a few cpp files in a project that is "pure" C .c files. The .c file is looking for a function object with syntax _FUNCTIONAME, like this:

logforwarder.obj : error LNK2001: unresolved external symbol _getEventLogProviders

but the .lib file exports it like this: Dump of file M:...\Release\recvevent.lib

File Type: LIBRARY

     Exports

       ordinal    name

                  ?_getEventLogProviders@@YAIPAPAD@Z (unsigned int __cdecl _getE
ventLogProviders(char * *))
开发者_JAVA技巧
  Summary

          C3 .debug$S
          14 .idata$2
          14 .idata$3
           4 .idata$4
           4 .idata$5
           C .idata$6

My exports.def file looks like this:

EXPORTS
 getEventLogProviders=getEventLogProviders @4

A library the project can link successfully, exports the functions like this:

Dump of file M:\...\screenshot.lib

File Type: LIBRARY

     Exports

       ordinal    name

                  _ReflectiveLoader@4

What am I doing wrong?


The decoration adds both the underscore at the beginning of the exported function and the @ with the number at the end. Your .def file should therefore look like this:

getEventLogProviders=_getEventLogProviders@4

As it is now, the .def doesn't have any effect, as the mangled function is not written correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜