C++ 有些复杂的Visual Studio解决方案中未解析的外部符号

C++ 有些复杂的Visual Studio解决方案中未解析的外部符号,c++,visual-studio-2010,visual-c++,unresolved-external,C++,Visual Studio 2010,Visual C++,Unresolved External,我一直在努力解决这个恼人的未解决的外部符号有一段时间了。我只是似乎没有找到错误在哪里,我的库似乎是链接的,但不知何故编译器没有看到它 2>win_main.obj : error LNK2019: unresolved external symbol "void * __cdecl nedalloc::nedmalloc(unsigned int)" (?nedmalloc@nedalloc@@YAPAXI@Z) referenced in function "private: stati

我一直在努力解决这个恼人的未解决的外部符号有一段时间了。我只是似乎没有找到错误在哪里,我的库似乎是链接的,但不知何故编译器没有看到它

2>win_main.obj : error LNK2019: unresolved external symbol "void * __cdecl nedalloc::nedmalloc(unsigned int)" (?nedmalloc@nedalloc@@YAPAXI@Z) referenced in function "private: static void * __cdecl Seventh::AllocatedObject::allocateBytes(unsigned int)" (?allocateBytes@AllocatedObject@Seventh@@CAPAXI@Z)
2>win_main.obj : error LNK2019: unresolved external symbol "void __cdecl nedalloc::nedfree(void *)" (?nedfree@nedalloc@@YAXPAX@Z) referenced in function "private: static void __cdecl Seventh::AllocatedObject::deallocateBytes(void *)" (?deallocateBytes@AllocatedObject@Seventh@@CAXPAX@Z)
2>C:\Users\X\X\X\SeventhEngine\Debug\SeventhEngineExamples.exe : fatal error LNK1120: 2 unresolved externals
我正在尝试链接nedmalloc dll导出库,我已经使用框架依赖项链接了它,还将其包含在其他库中。我还使用
NEDMALLOC\u DLL\u EXPORTS
编译了库,以确保
\u declspec(dllexport)
标志

如果您想查看,可以签出完整的源代码(包括VS2010解决方案和项目):

我几乎可以肯定这是一个设置问题。此外,请随时发布有关此设置的任何建议和评论

提前谢谢

更新

Dump of file nedmalloc.dll

File Type: DLL

  Section contains the following exports for nedmalloc.dll

    00000000 characteristics
    507C8192 time date stamp Mon Oct 15 23:35:14 2012
        0.00 version
           1 ordinal base
          43 number of functions
          43 number of names

    ordinal hint RVA      name

          1    0 000110FA nedblksize = @ILT+245(_nedblksize)
          2    1 0001129E nedcalloc = @ILT+665(_nedcalloc)
          3    2 00011069 nedcreatepool = @ILT+100(_nedcreatepool)
          4    3 00011041 neddestroypool = @ILT+60(_neddestroypool)
          5    4 000110FF neddestroysyspool = @ILT+250(_neddestroysyspool)
          6    5 00011050 neddisablethreadcache = @ILT+75(_neddisablethreadcache)
          7    6 0001121C nedflushlogs = @ILT+535(_nedflushlogs)
          8    7 00011203 nedfree = @ILT+510(_nedfree)
          9    8 0001138E nedfree2 = @ILT+905(_nedfree2)
         10    9 00011159 nedgetvalue = @ILT+340(_nedgetvalue)
         11    A 00011343 nedindependent_calloc = @ILT+830(_nedindependent_calloc)
         12    B 00011325 nedindependent_comalloc = @ILT+800(_nedindependent_comalloc)
         13    C 000112C1 nedmallinfo = @ILT+700(_nedmallinfo)
         14    D 0001126C nedmalloc = @ILT+615(_nedmalloc)
         15    E 00011055 nedmalloc2 = @ILT+80(_nedmalloc2)
         16    F 0001105F nedmalloc_footprint = @ILT+90(_nedmalloc_footprint)
         17   10 00011299 nedmalloc_internals = @ILT+660(_nedmalloc_internals)
         18   11 00011023 nedmalloc_stats = @ILT+30(_nedmalloc_stats)
         19   12 0001128F nedmalloc_trim = @ILT+650(_nedmalloc_trim)
         20   13 000110C3 nedmallopt = @ILT+190(_nedmallopt)
         21   14 000112BC nedmemalign = @ILT+695(_nedmemalign)
         22   15 000110AF nedmemsize = @ILT+170(_nedmemsize)
         23   16 00011073 nedpcalloc = @ILT+110(_nedpcalloc)
         24   17 000113CF nedpfree = @ILT+970(_nedpfree)
         25   18 00011253 nedpfree2 = @ILT+590(_nedpfree2)
         26   19 000112E9 nedpindependent_calloc = @ILT+740(_nedpindependent_calloc)
         27   1A 00011136 nedpindependent_comalloc = @ILT+305(_nedpindependent_comalloc)
         28   1B 000111F4 nedpmallinfo = @ILT+495(_nedpmallinfo)
         29   1C 000110AA nedpmalloc = @ILT+165(_nedpmalloc)
         30   1D 000112AD nedpmalloc2 = @ILT+680(_nedpmalloc2)
         31   1E 00011208 nedpmalloc_footprint = @ILT+515(_nedpmalloc_footprint)

         32   1F 000113A2 nedpmalloc_stats = @ILT+925(_nedpmalloc_stats)
         33   20 0001125D nedpmalloc_trim = @ILT+600(_nedpmalloc_trim)
         34   21 000112DF nedpmallopt = @ILT+730(_nedpmallopt)
         35   22 00011113 nedpmemalign = @ILT+270(_nedpmemalign)
         36   23 000112F8 nedpoollist = @ILT+755(_nedpoollist)
         37   24 0001119A nedprealloc = @ILT+405(_nedprealloc)
         38   25 000110F5 nedprealloc2 = @ILT+240(_nedprealloc2)
         39   26 000111B8 nedpsetvalue = @ILT+435(_nedpsetvalue)
         40   27 00011078 nedrealloc = @ILT+115(_nedrealloc)
         41   28 00011267 nedrealloc2 = @ILT+610(_nedrealloc2)
         42   29 00011311 nedsetvalue = @ILT+780(_nedsetvalue)
         43   2A 0001105A nedtrimthreadcache = @ILT+85(_nedtrimthreadcache)

  Summary

        1000 .data
        1000 .idata
        3000 .rdata
        1000 .reloc
        1000 .rsrc
       12000 .text
       10000 .textbss
中似乎存在一个“bug”(或设计),为了将函数标记为
extern“C”
,您还需要定义
NO\NED\u命名空间

#if defined(__cplusplus)
 #if !defined(NO_NED_NAMESPACE)
namespace nedalloc {
 #else
extern "C" {
 #endif
.
.
.

如您所见,
extern“C”
仅在
未定义名称空间时添加。

运行“dumpbin/exports nedmalloc.dll”以查看正在导出的符号的实际名称。发布时,不知道此实用程序!这是一个C库,你必须告诉C++编译器这样。是否包含nedmalloc头文件?这正是问题所在。当包含nedmalloc头文件时,我尝试使用
extern“C”
,但它给了我无数
模板无法声明为具有“C”链接的错误,因此我直接包含了源文件,编译效果非常好!