我一直在努力解决这个烦人的未解决的外部符号。我只是似乎没有找到错误的位置,我的库似乎链接,但不知何故编译器没有看到它。
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_DLL_EXPORTS
编译了库以确保__declspec(dllexport)
标记。
如果您想看看,可以查看完整的源代码(包括VS2010解决方案和项目):
https://github.com/albertofem/SeventhEngine
我几乎可以肯定这是一个设置问题。另外,请随时发布有关此设置的任何建议和意见。
提前致谢。
更新
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
答案 0 :(得分:0)
似乎有一个" bug" (或设计)为了将函数标记为extern "C"
,您还需要定义NO_NED_NAMESPACE
:
#if defined(__cplusplus)
#if !defined(NO_NED_NAMESPACE)
namespace nedalloc {
#else
extern "C" {
#endif
.
.
.
正如您所看到的,extern "C"
仅在定义NO_NED_NAMESPACE
时添加。