Link错误有很多种,主要是没有在连接中加入lib文件路径,或者lib配置正确,传参错误

一个solution里面多个project之间引用其他project函数会出现这个错误,由于包含了头文件而没处理lib文件导致,解决办法有如下几种:

1.在引用外部函数的cpp文件的头文件包含列表下添加 #pragma comment(lib, "xxx.lib")
2.在引用其他动态库的工程的Properties->Configuration Properties->Linker->Additional Dependencies中添加lib文件路径

3.在引用其他动态库的工程的Properties->Common Properties->Framework and References中Add New Reference选择依赖的工程

最近遇到一个问题,lib配置正确,传参也没问题,仍报LNK2019。。。。找了许久发现是引用dll中的函数而没有使用dll函数导出配置代码如下

   1: #pragma once

   2:  

   3: #include "..\..\third-part\plustache\context.hpp"

   4: #include "..\..\third-part\jsoncpp\json.h"

   5:  

   6: class DataConversion {

   7: public:

   8:     DataConversion();

   9:     ~DataConversion();

  10:     static Context JsonToContext(char *printData);

  11: private:

  12:     static PlustacheTypes::ObjectType ConvertObject(const Json::Value& json, Context* ctx);

  13:     static PlustacheTypes::CollectionType ConvertCollection(const Json::Value& json);

  14:     static void ConvertPrimative(const Json::Value& json, CString& value);

  15: }; 

  16: //上面代码是一个dll中的头文件,需要在其他工程中使用 Context JsonToContext(char *printData);这个函数,怎么调用都是连接错误,后来想到是dll函数导出的问题,于是修改成如下代码即可

  17: #pragma once

  18:  

  19: #ifdef PRINTERPLUGIN_EXPORTS

  20: #define PRINTERPLUGIN_API __declspec(dllexport)

  21: #else

  22: #define PRINTERPLUGIN_API __declspec(dllimport)

  23: #endif

  24:  

  25: #include "..\..\third-part\plustache\context.hpp"

  26: #include "..\..\third-part\jsoncpp\json.h"

  27:  

  28: class DataConversion {

  29: public:

  30:     DataConversion();

  31:     ~DataConversion();

  32:     PRINTERPLUGIN_API static Context JsonToContext(char *printData);

  33: private:

  34:     static PlustacheTypes::ObjectType ConvertObject(const Json::Value& json, Context* ctx);

  35:     static PlustacheTypes::CollectionType ConvertCollection(const Json::Value& json);

  36:     static void ConvertPrimative(const Json::Value& json, CString& value);

  37: };

VS2010编译错误 LNK 2019 unresolved external symbol错误解决办法的更多相关文章

  1. error LNK2001: unresolved external symbol _main解决办法(zz)

    error LNK2001: unresolved external symbol _main解决办法   解决外部符号错误:_main,_WinMain@16,__beginthreadex -!t ...

  2. OpenSceneGraph 编译 error LNK2019:unresolved external symbol 错误

    在编译 OpenSceneGraph 的一个简单示例时, #include <osgViewer/Viewer> #include <osgDB/ReadFile> void ...

  3. [异常] VC6.0 error LNK2001: unresolved external symbol _main解决办法

    来自:http://www.douban.com/note/65638800/ 学习VC++时经常会遇到链接错误LNK2001,该错误非常讨厌,因为对于编程者来说,最好改的错误莫过于编译错误,而一般说 ...

  4. VC6.0 error LNK2001: unresolved external symbol _main解决办法

    学习VC++时经常会遇到链接错误LNK2001,该错误非常讨厌,因为对于编程者来说,最好改的错误莫过于编译错误,而一般说来发生连接错误时,编译都已通过.产生连接错误的原因非常多,尤其LNK2001错误 ...

  5. 链接报error LNK2019: unresolved external symbol错误,解决

    http://blog.163.com/aiding_001/blog/static/22908192011102224344450/ 某次编写一个COM组件,接口定义好之后,增加了ZRX代码后编译链 ...

  6. unresolved external symbol __report_rangecheckfailure 解决思路

    __report_rangecheckfailure  是用来检查堆栈缓存溢出的,如果编译的时候打开GS(project property-->Configuration properties- ...

  7. VS2010中使用QtOpenGL出现 unresolved external symbol __imp__glClear@4 referenced in function之类的错误

    描述: 链接了QtOpenGL4.lib QtOpend4.lib的库啊,居然还是发生此错误. 原因是没有链接OpenGL32.lib这个库.所以,要添加这个lib 重新rebuild的一下,此类的错 ...

  8. 用keil编写的 C51错误 *** WARNING L1: UNRESOLVED EXTERNAL SYMBOL SYMBOL: ?C_START

    可能原因: 替换工程的文件未先 remove该文件. 正常替换文件步骤: 1. 右键 欲 替换的文件,remove  XXXXX.c from build  ----> remove  XXXX ...

  9. C++: Unresolved external symbol __imp__fscanf

    VS2019中遇到错误error LNK2001: unresolved external symbol __imp__fscanf 解决办法:链接legacy_stdio_definitions.l ...

随机推荐

  1. Defraggler(磁盘整理软件) V2.21.993 绿色版

    软件名称: Defraggler(磁盘整理软件) 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 5.0MB 图片预览: 软件简介: Defraggler ...

  2. idea新建项目文件名为红色的解决办法

    Perference->version Control ->Directory添加项目路径,vcs选<none> 即可.

  3. pgsql获取表相关数据

    import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.P ...

  4. 解决Intellij Idea里tomcat启动报The JRE_HOME environment variable is not defined correctly的错误

    创建一个maven项目后想启动tomcat测试一下新建的maven项目,结果一直报The JRE_HOME environment variable is not defined correctly, ...

  5. Winform ComBox模糊查询

    一.添加数据源并绑定 List<string> list = new List<string>(); list.Add("张三"); list.Add(&q ...

  6. git add -f

    git add -f 添加已被 .gitignore 忽略的文件/文件夹

  7. linux安装GraphicsMagick

    下载GraphicsMagick-1.3.21.tar.gz 解压:tar -zxvf GraphicsMagick-1.3.21.tar.gz cd /usr/local/GraphicsMagic ...

  8. 关于mongodb的一些笔记

    1.以服务的形式安装mongodb dos -- 进入到mongodb的bin目录下,执行 D:\mongodb\bin>mongod --logpath D:\mongodb\logs\mon ...

  9. hibernate------->第一个程序

    今天学习hibernate . 创建User类: package com.hibernate; import java.util.Date; public class User { private I ...

  10. Python基础(七)-文件操作

    一.文件处理流程 1.打开文件,得到文件句柄赋值给一个变量 2.通过句柄对文件进行操作 3.关闭文件 二.基本操作 f = open('zhuoge.txt') #打开文件 first_line = ...