C++ DLL编程时报错:无法解析的外部符号
来源:互联网 发布:编程语言特点 编辑:程序博客网 时间:2024/06/05 09:12
问题: 1error LNK2001: 无法解析的外部符号 _xMonitorFromPoint@12e:\visual studio 2010\Projects\myTest\ModifyResolutionC\ModifyResolutionC\modifyResolution.objModifyResolutionC;错误 2error LNK1120: 1 个无法解析的外部命令 e:\visual studio 2010\Projects\myTest\ModifyResolutionC\Debug\ModifyResolutionC.dll1 1 ModifyResolutionC
源文件:
ModifyResolutionC.h:
#ifndef FIRSTDLL_H#define FIRSTDLL_H#ifdef DLLEXPORT#define DLLOPTION _declspec(dllexport) //表明标有此宏定义的函数和类是dll文件的导出函数和类,是dll文件的对外接口#else#define DLLOPTION _declspec(dllimport) //表明标有此宏定义的函数和类的定义在dll文件中#endifextern "C" DLLOPTION char* getResolution(); #endif
ModifyResolutionC.cpp:
#include <iostream>#define DLLEXPORT //定义了预处理器变量 DLLEXPORT#include "modifyResolution.h"#include <windows.h>#include "multimon.h" #include <string.h>#include <Winuser.h>using namespace std;char* getResolution(){POINT p;p.x = 23;p.y =23;HMONITOR h = MonitorFromPoint(p,MONITOR_DEFAULTTONULL);return reinterpret_cast<char*>(h);//转换为char*}
MonitorFromPoint的功能参见:https://msdn.microsoft.com/en-us/library/dd145062(VS.85).aspx
此代码确认坐标是否在显示器上存在。
解决问题:
在网上也搜了很多,很多人说的是没有lib库,按照百度经验上去寻找依赖项http://jingyan.baidu.com/article/4d58d54135d7a79dd4e9c0ad.html,发现我用的user.lib是存在于依赖库中的。http://www.cnblogs.com/hiloves/p/4678848.html这篇文字还采取了恨铁不成钢的教育形式说是C和C++混编造成的,按照他的意思修改错误更多。后来想是不是在引入头文件中有多余的并没有依赖项,所以注销了多余引用的头文件:
#include "modifyResolution.h"#include <windows.h>//#include "multimon.h" //注销项#include <string.h>#include <Winuser.h>编译通过,在java中调用C++产生的dll文件成功。
- C++ DLL编程时报错:无法解析的外部符号
- VS2010封装DLL时报错:error LNK2019: 无法解析的外部符号 "__declspec(dllimport)
- DLL编程中的"error LNK2001: 无法解析的外部符号"错误
- C++ dll无法解析的外部符号的问题起因
- 无法解析的外部符号 dll中的函数不能识别
- dll导出(无法解析的外部符号 "__declspec(dllimport))
- MFC DLL报错:error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- 无法解析的外部符号
- bzoj 3288: Mato矩阵 线性筛
- 在AndroidStudio2.3.2下JNI开发的详细步骤
- SVM学习总结(二)SVM算法流程图
- 七牛云简单上传图片 展示
- AIDL基本使用3—-in out inout的用
- C++ DLL编程时报错:无法解析的外部符号
- swift回调的实现
- Google官方指导文章:开始用Kotlin开发Android
- python连hive
- mysql大批量更新数据
- Qt应用程序发布
- 获取网络的api 的例子
- js中几种实用的跨域方法原理详解
- Echarts之map地图隐藏港澳台等区域