Error LNK2019: unresolved external symbol
2012-05-20 20:38
411 查看
最近写的程序一个solution里有两个projects,一个c++的project要调用c project,编译的时候一直出现link error,Error LNK2019: unresolved external symbol。查了好长时间才发现下面的解决方法,很不错。
http://blogs.msdn.com/vsdteam/archive/2005/11/20/495123.aspx
Error LNK2019: unresolved external symbol int __cdecl CeMountDBVolEx, void * __cdecl CeOpenDatabaseInSession
You have created a C++ device project and using the EDB methods from "coredll.lib". You have included the "windbase_edb.h" file in your projects
source files. When you compile and link this you are getting following linker errors
error LNK2019: unresolved external symbol "int __cdecl CeMountDBVolEx(struct _CEGUID *,wchar_t *,struct _CEVOLUMEOPTIONS *,unsigned long)" (?CeMountDBVolEx@@YAHPAU_CEGUID@@PA_WPAU_CEVOLUMEOPTIONS@@K@Z)
referenced in function "int __cdecl MountDbVol(void)" (?MountDbVol@@YAHXZ)
error LNK2019: unresolved external symbol "void * __cdecl CeOpenDatabaseInSession(void *,struct _CEGUID *,unsigned long *,wchar_t *,struct _SORTORDERSPECEX
*,unsigned long,struct _CENOTIFYREQUEST *)" (?CeOpenDatabaseInSession@@YAPAXPAXPAU_CEGUID@@PAKPA_WPAU_SORTORDERSPECEX@@KPAU_CENOTIFYREQUEST@@@Z)
and you are wondering why this is happening?
The problem with your project is that you are using a "C" style exported library in your C++ projects. When the compiler generates mangled names
for C++ functions, they are different from unmangled names generated by the C compiler and hence the C++ compiler will not be able to link with the methods imported from coredll.lib.
The solution to this problem is - while including the header windbase_edb.h, you can explicitly tell the compiler that all functions included
from this header are "C" style functions by changing your inclusion as below.
extern "C"
{
#include
}
With this the C++ compiler when includes the declarations from the windbase_edb.h file, it does not do any name mangling for the functions declared
in this file, and thus you should be able to link to EDB without any problems now.
版权声明:以上内容皆摘自网上,仅供参考学习!
转自:http://www.cppblog.com/Dutyboy/archive/2010/11/19/134082.html
http://blogs.msdn.com/vsdteam/archive/2005/11/20/495123.aspx
Error LNK2019: unresolved external symbol int __cdecl CeMountDBVolEx, void * __cdecl CeOpenDatabaseInSession
You have created a C++ device project and using the EDB methods from "coredll.lib". You have included the "windbase_edb.h" file in your projects
source files. When you compile and link this you are getting following linker errors
error LNK2019: unresolved external symbol "int __cdecl CeMountDBVolEx(struct _CEGUID *,wchar_t *,struct _CEVOLUMEOPTIONS *,unsigned long)" (?CeMountDBVolEx@@YAHPAU_CEGUID@@PA_WPAU_CEVOLUMEOPTIONS@@K@Z)
referenced in function "int __cdecl MountDbVol(void)" (?MountDbVol@@YAHXZ)
error LNK2019: unresolved external symbol "void * __cdecl CeOpenDatabaseInSession(void *,struct _CEGUID *,unsigned long *,wchar_t *,struct _SORTORDERSPECEX
*,unsigned long,struct _CENOTIFYREQUEST *)" (?CeOpenDatabaseInSession@@YAPAXPAXPAU_CEGUID@@PAKPA_WPAU_SORTORDERSPECEX@@KPAU_CENOTIFYREQUEST@@@Z)
and you are wondering why this is happening?
The problem with your project is that you are using a "C" style exported library in your C++ projects. When the compiler generates mangled names
for C++ functions, they are different from unmangled names generated by the C compiler and hence the C++ compiler will not be able to link with the methods imported from coredll.lib.
The solution to this problem is - while including the header windbase_edb.h, you can explicitly tell the compiler that all functions included
from this header are "C" style functions by changing your inclusion as below.
extern "C"
{
#include
}
With this the C++ compiler when includes the declarations from the windbase_edb.h file, it does not do any name mangling for the functions declared
in this file, and thus you should be able to link to EDB without any problems now.
版权声明:以上内容皆摘自网上,仅供参考学习!
转自:http://www.cppblog.com/Dutyboy/archive/2010/11/19/134082.html
相关文章推荐
- error LNK2019: unresolved external symbol _va_end referenced in function _fatal_error
- error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
- error LNK2019:unresolved external symbol *** referenced in function ***的解决方案
- error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup 2011.10.29
- error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _wmain
- error LNK2019: unresolved external symbol _viOpen@20 referenced in function _main
- error LNK2019: unresolved external symbol @24问题
- error LNK2019: unresolved external symbol
- [转]error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- 模板实例化函数链接出错:error LNK2019: unresolved external symbol
- VS2015 MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
- 关于error LNK2019::Unresolved External Symbol * Referenced In Function..解决办法 2
- 链接错误:error LNK 2019 :Unresolved external symbol
- error LNK2019: unresolved external symbol 问题
- error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- 关于"error LNK2019: unresolved external symbol _SipShowIM referenced in function "protected" 解决方法
- error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
- 编译UltraVNC时的Debug版本时遇到vncclient.obj : error LNK2019: unresolved external symbol _compress等错误
- widget.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl
- OpenGL项目出现错误:error LNK2019: unresolved external symbol _gluErrorString@4