首页 > 编程语言 > 详细

C++ 链接错误 LNK2019,LNK2001

时间:2017-10-19 15:39:46      阅读:300      评论:0      收藏:0      [点我收藏+]

LNK2019 c和c++混合编程

解决方法: 对c编写的部分,添加

#ifdef __cplusplus
extern "C" {
#endif

 

#ifdef __cplusplus
}
#endif

到其头文件中。

 

注意构造函数和析构函数的实现

CHtMotion_extern(void){  };

 

当前项目源文件路径里没有相应的文件。

include其他工程的头文件后,也要include相应的函数实现的文件。不然只有声明,没有实现,就链接不了。

.c只include一次,不然会有重命名问题。

 

LNK2001  google test 框架 TEST_F用法

class CHtMotion_test : public testing::Test //不需要继承CHtMotion_extern类
{
protected:
CHtMotion_extern* test;
virtual void SetUp(){
this->test = new CHtMotion_extern;
}

virtual void TearDown(){
delete this->test;
}
};

 

C++ 链接错误 LNK2019,LNK2001

原文:http://www.cnblogs.com/mmmushroom/p/7692709.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!