c/objectivec/win32/mfc/qt 异常处理与总结

实际异常一:
libcpmtd.lib(xmbtowc.obj) : error LNK2001: unresolved external symbol __CrtDbgReport
Debug/B机.exe : fatal error LNK1120: 1 unresolved externals
处理办法:
property pages->Configuration Propertyies->C/C++->Code Generation->Runtime Library->Multi-threaded Debug(/MTd)


实际异常二:
Error 30 error C3861: 'CryptReleaseContext': identifier not found c:\users\administrator\desktop\mywin32http-dll\common\include\stringprocess.h 472 1 MyWin32Http-dll
处理方法:
#define _WIN32_WINNT 0x0502


实际异常三:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
处理方法:
project->BaseClasses properties->configuration->C/C++ ->Command Line,增加/wd4430选项。

实际异常四:

中文乱码,单字节字符(vc6)、Unicode(vc8 vc9 vc10)

处理方法:

property pages->Configuration Propertyies->General->Character Set->Use Multi-Byte Character Set

 实际异常五:

VC++ 2008编译错误fatal error C1902问题的解决

处理方法:

将C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\mspdbsrv.exe复制到C:\Program Files\Microsoft Visual Studio 9.0\VC\bin下即可。

实际异常六 :

error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup

处理方法:

1.Linker->Advanced页,将Entry Point由wWinMainCRTStartup改成WinMainCRTStartup

2.Configuration Properties->C/C++->Preprocessor,然后在右边栏的Preprocessor Definitions对应的项中删除_CONSOLE, 添加_WINDOWS.
3.Configuration Properties->Linker->System,然后在右边栏的SubSystem对应的项改为Windows(/SUBSYSTEM:WINDOWS)

4.检查是否存在C的引用,如有则加上extern "C"{ }

  

 实际异常七:

处理方法:

在stdafx.h文件最上面加入#define _USE_32BIT_TIME_T

实际异常八:

Run-Time Check Failure #2 - Stack around the variable 'dect' was corrupted.

处理方法:

C/C++->Code Generation->Basic Runtime Checks=Default

实际异常九:

vc2005及以上和6.0的DLL导出函数中有wchar_t, 都无法被对方使用, 必须在vc2005及以上版本中做如下设置

处理方法:

C/C++-->Language->Treat wchar_t as Built-in Type --> No (/Zc:wchar_t-)

实际异常十:

Error 2 error C1189: #error :  This file requires _WIN32_WINNT to be #defined at least to 0x0500. Value 0x0501 or higher is recommended. c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxcomctl32.h 23 1 XPFace
处理方法

#ifndef WINVER 0x0500
#define _WIN32_WINNT 0x0500
#endif

实际异常十一:

afximpl.h中MENUGETOBJECTINFO、HRAWINPUT找不到而出错。

处理方法:

typedef struct tagMENUGETOBJECTINFO {
 DWORD dwFlags;
 UINT  uPos;
 HMENU hmenu;
 PVOID riid;
 PVOID pvObj;
} MENUGETOBJECTINFO, *PMENUGETOBJECTINFO;

typedef struct HRAWINPUT__ * HRAWINPUT;

实际异常十二:

Error 125 error LNK1104: cannot open file 'LIBC.lib' C:\test\LINK test

处理方法:

Configuration Properties->Linker->Input->Ignore Specific Default Libraries=libc.lib

实际异常十三:x264

Error 220 error LNK2019: unresolved external symbol _strtok_r referenced in function _parse_zones D:\x264\build\win32\libx264.lib(ratecontrol.obj) x264
Error 221 error LNK1120: 1 unresolved externals D:\x264\build\win32\bin\x264.exe 1 1 x264

处理方法:

将\x264\common\osdep.h中#ifdef __WIN32__改为#ifdef WIN32

实际异常十四:

Error 150 error LNK1123: failure during conversion to COFF: file invalid or corrupt C:\video\LINK creenVideo
Error 149 error CVT1100: duplicate resource.  type:MANIFEST, name:1, language:0x0413 C:\video\CVTRES creenVideo

处理方法:

1. Project propert\ linker\ 启用增量链接:否;(关闭增量链接)
2. 设置工程属性->配置属性-> 清单工具->输入和输出->嵌入清单,选择[否]
3. 在工程的.rc文件里面删除了manifest块. 删除VC6.0外部Manifest文件。设置生成嵌入式清单,并在附加清单依赖项: Microsoft.Windows.Common-Controls。

实际异常十五:

C++调用C函数找不到。

处理方法:

#ifdef __cplusplus

extern "C" {

#endif

int ConvertScreen(int width, int height, const char * src, char * dest);

#ifdef __cplusplus

}

#endif

实际异常十六:

 13 IntelliSense: a value of type "void *" cannot be assigned to an entity of type "uint8_t  *" s:\test\main.c 749 24 Test

处理方法:

函数体内,变量声明必须在开始处,不得在语句中或之后。

实际异常十七:
Error 1 error C3861: 'AtlLoadSystemLibraryUsingFullPath': identifier not found c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atltransactionmanager.h 312 1 TestMfc

处理方法:

AtlLoadSystemLibraryUsingFullPath改为LoadLibraryW

实际异常十八:

....could not be opened because the microsoft visual C# 2010 compiler could not be created

处理方法:

打开注册表直接删除HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0即可

实际异常十九:

error C2668: 'pow' : ambiguous call to overloaded function

处理方法:

在vs03或者vc6.0里,可以直接写成:pow(i, 2)

在vs05和vs2008中需要改成:pow((double)i, 2),需要给i一个确定的类型。

实际异常二十: 

error C1083: Cannot open include file Permission denied

处理方法:

修改引用中路径为正确即可

 实际异常二十一:

Compiler Error C2146 syntax error : missing 'token' before identifier 'identifier'
处理方法:
检查是否没有给类型添加相应的引用

 实际异常二十二:

Error 89 error MSB6006: "cmd.exe" exited with code 9009. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets 151 6 libx264

处理方法:

安装相应的汇编编译器并复制其主程序到vc\bin文件夹下即可。

实际异常二十三:

Error 1 error C1083: Cannot open include file: 'streams.h': No such file or directory d:\users\administrator\desktop\amcap\stdafx.h 23 1 AmCap
处理方法:

安装DirectX 9.0B SDK,里面有directshow相应的资源,之后版本的sdk,directshow被并到windows platform sdk里去了。

实际异常二十四:

/lib/ld-linux.so.2:bad ELF interpreter:No such file or directory

处理方法:

yum install glibc.i686

实际异常二十五:(qt)

Qwt is configured without SVG support

处理方法:

打开qtconfig.pri,把QWT_CONFIG     += QwtSvg 屏蔽掉

实际异常二十六:

ARC forbids explicit message send of 'autorelease' (release)
处理方法:
release' is unavailable: not available inautomatic reference counting mode

Edit->Refactor->Convert to Objective-C ARC

实际异步二十七:

Error 1 error C4996: 'fopen': This function or variable may be unsafe.
处理方法:
方法一:将原来的旧函数替换成新的Security CRT functions。
方法二:用以下方法屏蔽这个警告。
1.在预编译头文件stdafx.h里(注意:一定要在没有include任何头文件之前)定义下面的宏:
  #define _CRT_SECURE_NO_DEPRECATE
2.#param warning(disable:4996)
3.更改预处理定义:
  项目->属性->配置属性->C/C++ -> 预处理器 -> 预处理器定义,增加_CRT_SECURE_NO_DEPRECATE
方法三:方法二没有使用新的更安全的CRT函数,显然不是一个值得推荐的方法,可是你又不想一个一个地改,那么还有一个更方便的方法:
  在预编译头文件stdafx.h里(同样要在没有include任何头文件之前)定义下面的宏:
  #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
  在链接的时候便会自动将旧函数替换成Security CRT functions。
注意:这个方法虽然使用了新的函数,但是不能消除警告(原因见红字),你还得同时使用方法

 实际异常二十八:

 Error C2664: 'std::map<_Kty,_Ty>::map(const std::less<_Ty> &)' : cannot convert parameter 1 from 'const std::pair<_Ty1,_Ty2>' to 'const std::less<_Ty> &'
处理方法:
方法一:
map<int,map<int,int>> coll;
map<int,int> temp;
temp.insert(make_pair(1,1));
coll.insert(make_pair(7,temp));
方法二:
map<int,pair<int,int>> coll;
coll.insert(make_pair(7,make_pair(1,1)));
方法三:
map<int,map<int,int>> coll;
coll.insert(make_pair(7,map<int,int>().insert(1,1)));

实际异常二十九:

terminate called after throwing an instance of 'std::bad_alloc'   what():  std::bad_alloc Aborted

处理方法:
解决内存泄露

实际异常三十:
Error 1 error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

处理方法:
配置属性->c/c++->Preprocessor->Preprocessor Definitions->加上_CRT_SECURE_NO_WARNINGS

实际异常三十一:

0xc000007b的解决办法

处理办法:

安装dx,参考

http://blog.csdn.net/VBcom/article/details/6218535
http://blog.csdn.net/VBcom/article/details/6070705

实际异常三十二:(Qt5)

错误:C2001: 常量中有换行符
错误:C2143: 语法错误 : 缺少“;”(在“}”的前面)

处理办法:

QStringtype="代码表";
改为
QStringtype="代码表\0";

实际异常三十三:(Qt5)

Failed to load platform plugin "windows"

处理办法:

将Qt安装文件夹中platforms文件夹复制到应用程序目录下即可

实际异常三十四:(Qt5)

C:\Qt\Qt5.0.1msvc2010\5.0.1\msvc2010\include\QtCore\qdatetime.h:123: 错误:C2589: '(' : illegal token on right side of '::'
private:
    static inline qint64 nullJd() { return std::numeric_limits<qint64>::min(); }
    static inline qint64 minJd() { return Q_INT64_C(-784350574879); }
    static inline qint64 maxJd() { return Q_INT64_C( 784354017364); }

处理办法:

#undef min

 实际异常三十五

Error 5 error C2440: '=' : cannot convert from 'void *' to 'RTPpacket_t *' c:\users\enost_000\desktop\rtpforh264\rtpreceiver\rtpreceiver.cpp 336 1 RTPReceiver

处理办法:

if ((p=malloc (sizeof (RTPpacket_t)))== NULL)

改为

if ((p=(RTPpacket_t*)malloc (sizeof (RTPpacket_t)))== NULL)

 实际异常三十六

Error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CSizingControlBarG::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint)' Cast from base to derived requires dynamic_cast or static_cast

处理办法:

UINT CSizingControlBarG::OnNcHitTest(CPoint point)  换成 LRESULT CSizingControlBarG::OnNcHitTest(CPoint point)

 实际异常三十七

Error 1 error C1083: Cannot open include file: 'fstream.h': No such file or directory d:\users\administrator\desktop\a\a.h 9 1 a

处理办法:

将  #include "'fstream.h"  更改为:

#include <fstream>
using namespace std;

实际异常三十八

Error 11 error LNK1295: '/MANIFESTUAC' not compatible with '/DRIVER' specification; link without '/MANIFESTUAC' d:\Users\Administrator\Desktop\a\LINK keyboardspy

处理办法:

用文本方式打开工程文件,搜索"/MANIFESTUAC",将搜索到的那一行删除。

实际异常三十九 (android studio)

Gradle:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':MySocket:compileDebug'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

处理办法:

工程所在目录下使用命令行:gradlew compileDebug --stacktrace

 实际异常四十

 cpu.c:-1: 错误:undefined reference to `_imp__pthread_num_processors_np'

处理办法

1、配置编译时使用:--disable-pthreads

2、使用:pthreadVC2.lib、pthreadVC2.dll

 实际异常四十一

 error C3861: “UINT64_C”: 找不到标识符

处理办法

在common.h中添加如下代码:
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif

 实际异常四十二

无法打开包括文件:“inttypes.h”: No such file or directory

处理办法

删除之,并在其之前添加如下代码:
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
# define CONFIG_WIN32
#endif
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(EMULATE_INTTYPES)
# define EMULATE_INTTYPES
#endif
#ifndef EMULATE_INTTYPES
# include <inttypes.h>
#else
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
# ifdef CONFIG_WIN32
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
# else /* other OS */
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
# endif /* other OS */
#endif /* EMULATE_INTTYPES */

实际异常四十三

CLR 无法从 COM 上下文 0xd48778 转换为 COM 上下文 0xd486c0,这种状态已持续 60 秒。拥有目标上下文/单元的线程很有可能执行的是非泵式等待或者在不发送 Windows 消息的情况下处理一个运行时间非常长的操作。这种情况通常会影响到性能,甚至可能导致应用程序不响应或者使用的内存随时间不断累积。要避免此问题,所有单线程单元(STA)线程都应使用泵式等待基元(如 CoWaitForMultipleHandles),并在运行时间很长的操作过程中定期发送消息。

Debug=>Exceptions=>ContextSwitchDeadlock 取消打勾

1、在vs2005环境中,debug菜单--〉Exception,把ContextSwitchDeadlock选项勾掉。
2、在配置文件中加入<mdaConfig>节,屏蔽该异常
把vs2005菜单的 调试->异常->Managed Debuggin Assistants->LoaderLock 的选中状态去掉
如果异常(exception)这一项没有的话,在工具---自定义---命令选项卡---左边选择调试--右边把异常托到菜单里
快捷键Ctrl+Alt+E,修改Managed Debuggin Assistants->LoaderLock 的选中状态去掉

实际异常四十四

软件包 javax.servlet 不存在
软件包javax.servlet.http 不存在

解决办法:
从tomcat lib目录下拷贝一个servlet-api.jar的包到“JDK\jre\lib\ext”目录下。凡是出现找不到包的情况,都可以将找到的包放到JDK\jre\lib\ext下,然后再编译就能够通过。
从resin目录下拷贝jsdk*.jar到“JDK\jre\lib\ext”目录下。

原文地址:https://www.cnblogs.com/chuncn/p/1916400.html