Visual Studio C++ 2010 链接错误
我收到几个 error LNK2019: unresolved external symbol
错误,但它们不是由 dll
、lib
或 OO 错误引起的正如关于此链接错误的所有其他 StackOverflow 帖子一样。
代码:
https://github.com/mcandre/fgdump/tree/master/cachedump
跟踪:
1>------ Build started: Project: cachedump, Configuration: Release Win32 ------
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl rc4_crypt(struct rc4_state *,unsigned char *,int)" (?rc4_crypt@@YAXPAUrc4_state@@PAEH@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl rc4_setup(struct rc4_state *,unsigned char *,int)" (?rc4_setup@@YAXPAUrc4_state@@PAEH@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl md5_finish(struct md5_context *,unsigned char * const)" (?md5_finish@@YAXPAUmd5_context@@QAE@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl md5_update(struct md5_context *,unsigned char *,unsigned long)" (?md5_update@@YAXPAUmd5_context@@PAEK@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl md5_starts(struct md5_context *)" (?md5_starts@@YAXPAUmd5_context@@@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>C:\Users\andrew\Desktop\src\fgdump\cachedump\Release\cachedump.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
abc
I'm getting several error LNK2019: unresolved external symbol
errors, but they're not due to dll
s, lib
s, or OO errors as in every other StackOverflow post about this link error.
Code:
https://github.com/mcandre/fgdump/tree/master/cachedump
Trace:
1>------ Build started: Project: cachedump, Configuration: Release Win32 ------
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl rc4_crypt(struct rc4_state *,unsigned char *,int)" (?rc4_crypt@@YAXPAUrc4_state@@PAEH@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl rc4_setup(struct rc4_state *,unsigned char *,int)" (?rc4_setup@@YAXPAUrc4_state@@PAEH@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl md5_finish(struct md5_context *,unsigned char * const)" (?md5_finish@@YAXPAUmd5_context@@QAE@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl md5_update(struct md5_context *,unsigned char *,unsigned long)" (?md5_update@@YAXPAUmd5_context@@PAEK@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>cachedump.obj : error LNK2019: unresolved external symbol "void __cdecl md5_starts(struct md5_context *)" (?md5_starts@@YAXPAUmd5_context@@@Z) referenced in function "unsigned long __cdecl DumpCache(void)" (?DumpCache@@YAKXZ)
1>C:\Users\andrew\Desktop\src\fgdump\cachedump\Release\cachedump.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
abc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.c
文件由cl
编译为C
代码,而.cpp
文件则编译为C++代码。由于
C
和C++
代码中符号定义的差异,您的C++
代码无法看到C
代码中的函数。在标头中使用
extern "C"
包装器,或者最好在整个项目中使用相同的语言要使
extern "C"
包装器使用以下模板.c
files are compiled bycl
asC
code, while.cpp
files are compiles asC++
code. Due to difference of symbols definitions inC
andC++
code yourC++
code can't see functions fromC
code.Use
extern "C"
wrapper in headers, or better use same language for the whole projectTo make
extern "C"
wrapper use the following template