解决Error LNK2019: unresolved external symbol

本文提供两种解决C++项目中使用C风格导出库导致的链接问题的方法。一是通过在包含头文件时声明extern C来避免名称修饰;二是检查并修正项目属性设置中的依赖项配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

解决方案一:

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 <windbase_edb.h>
}


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.


解决方案二:

最可能的原因就是lib配置出了问题,到Property->Linker->Input->Additional Dependencies里面查看类库是否配置有错误。

一般都是根据Errorlist里提示的lib文件进行寻找,有时多配了也不行,就是没有用到这个lib你配进去了可能也会出问题之类的...

一般都是少配了,或者debug版本的配成了release的等等。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值