错误 LNK2019:无法解析的外部的符号 _sscanf和_vsprintf
在使用Visual Studio 编译的时候可能会遇到 ERROR LNK2019:无法解析的外部的符号 _sscanf, _sscanf_s这样的函数,特别是使用Visual Studio2017时:
解决方法:
方法一:点击项目–属性,弹出属性对话框后,打开“链接器”点击输入,在“附加依赖项”中添加legacy_stdio_definitions.lib 即可。
方法二:在报错的.cpp文件中的头文件下面加#parameter(lib,"legacy_stdio_definitions.lib ")
提示:由于很多时候我们难以找到具体出错的.cpp文件,所以方法一更好用
E1097: unknown attribute "no_init_all" in WinNT.h in Windows SDK 10.0.18362.0
在我使用最新(2019.5.12)的VS2019(版本号16.0.3)时,编译器弹出了如标题所示错误,找不到"no_init_all"的attribute。错误源头在winnt.h这一系统头文件中。
只需要在winnt.h头文件中
#if (_MSC_VER >= 1915)
#pragma warning(disable:4845) // __declspec(no_init_all) used but d1initall not set
#endif
(这一代码块是微软工程师用于在旧版本的VS中消除该错误提示的预编译头
虽然微软的工程师们宣称他们在最新的VS2019中已经修复了该错误,但是仍有很多人受到了该错误的困扰。)
这一预编译头之后加上
#if (_MSC_VER >= 1915)
#define no_init_all deprecated
#endif
“ACCESS_MASK“不明确的符号 问题解决
opencv的命名控件 与 系统库名称冲突;
解决方式:
去除所有的using namespace cv
然后以cv::
替代
directshow 遇到的问题
具体是d3dx9.h D3DApp.h D3DFont.h 与qedit.h不能共存,出现一下错误:
should not include d3dtypes.h when compiling for DX8 or newer interfaces
D:\DXSDK\Include\d3drmobj.h(46) : warning C4005: 'WIN_TYPES' : macro redefinition
D:\DXSDK\Include\dxfile.h(48) : see previous definition of 'WIN_TYPES'
D:\DXSDK\Include\d3drmobj.h(274) : error C2061: syntax error : identifier 'LPDIRECT3D'
D:\DXSDK\Include\d3drmobj.h(299) : error C2061: syntax error : identifier 'LPDIRECT3DDEVICE'
D:\DXSDK\Include\d3drmobj.h(314) : error C2061: syntax error : identifier 'LPDIRECT3D'
D:\DXSDK\Include\d3drmobj.h(339) : error C2061: syntax error : identifier 'LPDIRECT3DDEVICE'
D:\DXSDK\Include\d3drmobj.h(344) : error C2061: syntax error : identifier 'LPDIRECT3D2'
D:\DXSDK\Include\d3drmobj.h(348) : error C2061: syntax error : identifier 'LPDIRECT3DDEVICE2'
D:\DXSDK\Include\d3drmobj.h(363) : error C2061: syntax error : identifier 'LPDIRECT3D'
D:\DXSDK\Include\d3drmobj.h(388) : error C2061: syntax error : identifier 'LPDIRECT3DDEVICE'
D:\DXSDK\Include\d3drmobj.h(393) : error C2061: syntax error : identifier 'LPDIRECT3D2'
D:\DXSDK\Include\d3drmobj.h(397) : error C2061: syntax error : identifier 'LPDIRECT3DDEVICE2'
D:\DXSDK\Include\d3drmobj.h(454) : error C2061: syntax error : identifier 'LPDIRECT3DVIEWPORT'
D:\DXSDK\Include\d3drmobj.h(500) : error C2061: syntax error : identifier 'LPDIRECT3DVIEWPORT'
D:\DXSDK\Include\d3drm.h(74) : error C2061: syntax error : identifier 'LPDIRECT3D'
D:\DXSDK\Include\d3drm.h(156) : error C2061: syntax error : identifier 'LPDIRECT3D2'
D:\DXSDK\Include\d3drm.h(240) : error C2061: syntax error : identifier 'LPDIRECT3D2' j
解决方法:#define __D3DRM_H__
在"stdafx.h"文件中,加上 #define __D3DRM_H__ 就好了