VC++遇到的问题.doc
《VC++遇到的问题.doc》由会员分享,可在线阅读,更多相关《VC++遇到的问题.doc(33页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、一. (2013/3/17遇到)unresolved external symbol _endthreadex错误解决在用VC6.0写程序调试时,初学者总是会遇到一些错误,针对如下错误主要是因为MFC类库没有引用所出现的问题。错误现象:nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol _endthreadexnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol _beginthreadexDebug/jnHid.exe
2、: fatal error LNK1120: 2 unresolved externalsError executing link.exe.解决错误的方法:选择ProjectSettings-General-Microsoft foundation Classes下拉列表中有三个选项: 1、Not using MFC 2、Use MFC in a Static Libray 3、Use MFC in a Shared DLL二unresolved external symbol _endthreadex错误解决在用VC6.0写程序调试时,初学者总是会遇到一些错误,针对如下错误主要是因为MFC类
3、库没有引用所出现的问题。错误现象:nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol _endthreadexnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol _beginthreadexDebug/jnHid.exe : fatal error LNK1120: 2 unresolved externalsError executing link.exe.解决错误的方法:选择ProjectSettings-Gener
4、al-Microsoft foundation Classes下拉列表中有三个选项:1、Not using MFC2、Use MFC in a Static Libray3、Use MFC in a Shared DLL本文来自CSDN博客,转载请标明出处:错误提示:nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol _endthreadexnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol _beginthreadex
5、libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _mainDebug/Hello.exe : fatal error LNK1120: 3 unresolved externals第一种解决方法:1、“Project”-“settings”-“c/c+”“Catagory” 选择“Code Generation”“use run-time library”选择“debug multithreaded”此时确定一般解决问题,也有可能出现如下问题提示:libcmtd.lib(crt0.obj) : error LNK2
6、001: unresolved external symbol _mainDebug/Hello.exe : fatal error LNK1120: 1 unresolved externals此时,进行第二步操作:2、Project - Settings - 选择Link属性页,在Project Options中将/subsystem:console改成/subsystem:windows温馨提示:在Project Options窗口,右边滑动条向下滑动就会找到该项!总结:进行以上两步操作后,问题解决!第二种解决方法:1.检查是否包含头文件afx.h2.打开project-settings
7、-general-microsoft foundation classes-选use MFC in a static library或选 use MFC in a shared DLL(需要把MFC的动态库放在system32文件夹下) .本人是碰到的nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol _endthreadexnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol _beginthreadex这两行错误,故用
8、第二种方法解决,分析原因是我调用了MFC类库,但建立的控制台程序默认不加载MFC类库,故需要改此处设置。第一种方法是在网上搜的,碰到类似的问题可以尝试一下。三(2013/3/18遇到)#include using namespace std;然后编译时出现 error C2871: std : does not exist or is not a namespace查了一下,原来 C+有两个不同版本的头文件。引入名字空间这个概念以前编译器用的是#include ,而引入名字空间的概念以后std名字空间的头文件名字变成了。是比较老的C+的头文件的版本,而namespace是98年才被加入C+标准
9、的,所以里面是没有std这么个命名空间的,当使用 时,相当于在c中调用库函数,使用的是全局命名空间,也就是早期的c+实现。头文件则没有定义全局命名空间,使用时必须使用namespace std才能正确使用cout。vc6.0支持这个两个版本. 不过现在都用了 所以只需将以上语句改为:#include using namespace std;或者是 #include 即可。四(2013/3/18遇到)cinabendl; 输入流中不能加“endl;”D:Program FilesMicrosoft Visual StudioMyProjectssumsum.cpp(7) : error C267
10、9: binary : no operator defined which takes a right-hand operand of type class ostream &(_cdecl *)(class ostream &) (or there is no acceptable conversion)D:Program FilesMicrosoft Visual StudioMyProjectssumsum.cpp(12) : warning C4508: main : function should return a value; void return type assumed执行
11、cl.exe 时出错.五(2013/3/18遇到)#include int max(int a,int b)if(ab)return a;else return b;int main()int x,y,max; / int x,y,m;coutPlease input two numbers:endl; / coutPlease input two numbers:xy; /cinxy;max = max(x,y); / m = max(x,y);coutThe max value of x and y is maxendl;/ coutThe max value of x and y is
12、mnum;cinscore;void display()coutnum = numendl;coutscore = scoreendl;D:Program FilesMicrosoft Visual StudioMyProjectsclassclass.cpp(22) : error C2146: syntax error : missing ; before identifier stu1D:Program FilesMicrosoft Visual StudioMyProjectsclassclass.cpp(22) : fatal error C1004: unexpected end
13、of file found执行 cl.exe 时出错.七(2013/3/19遇到)#include #include /#include using namespace std;d:program filesmicrosoft visual studiomyprojectsdecimal pointdecimal point.cpp(2) : fatal error C1083: Cannot open include file: iomainp: No such file or directory执行 cl.exe 时出错.coutsetiosflags(ios:fixed)setiosfl
14、ags(ios:right)setpricision(2);coutsetiosflags(ios:fixed)setiosflags(ios:right)setprecision(2);D:Program FilesMicrosoft Visual StudioMyProjectsdecimal pointdecimal point.cpp(8) : error C2065: setpricision : undeclared identifier执行 cl.exe 时出错.八(2013/3/19遇到)#include /#include (把这一行的注释符号去掉,就正确了。上一行有没有都行
15、)int main()char a,b,c;a = B;b = O;c = Y;putchar(a);putchar(b);putchar(c);putchar(n);return 0;d:program filesmicrosoft visual studiomyprojectsiosios.cpp(10) : error C2065: putchar : undeclared identifier执行 cl.exe 时出错.九(2013/3/19遇到)#include #include int main()int a;float b;char c;scanf(%d%f%c,&a,&b,&c
16、);printf(a = %d,b = %f,c = %c,&a,&b,&c);(多了三个&符号)D:Program FilesMicrosoft Visual StudioMyProjectsprintfscanfprintfscanf.cpp(11) : warning C4508: main : function should return a value; void return type assumedLinking.printfscanf.exe - 0 error(s), 0 warning(s)#include #include int main()int a;float b;
17、char c;scanf(%d%f%c,&a,&b,&c);printf(a = %d,b = %f,c = %cn,a,b,c);return 0;#include #include int main()int a;float b;char c;scanf(%d %f %c,&a,&b,&c);(在%d%f%c中加了两个空格键,本来不显示的c =后面的弄显示了出来)printf(a = %d,b = %f,c = %cn,a,b,c);return 0;十(2013/3/19遇到)x2 = (-b-sqrt(b*b-4*a*c)/2a;(应该是2*a)D:Program FilesMicro
18、soft Visual StudioMyProjectsequationequation.cpp(21) : error C2059: syntax error : bad suffix on number十一(2013/3/22遇到)p/4 = p/4 + (-1)(i-1)/(2*i - 1);d:program filesmicrosoft visual studiomyprojects的近似值的近似值.cpp(9) : error C2296: : illegal, left operand has type doubled:program filesmicrosoft visual
19、studiomyprojects的近似值的近似值.cpp(9) : error C2297: : illegal, right operand has type double意思是:“非法运算。原因,你左边的操作数是 double 型。”通常是你的程序有语法错误,编译器理解为 左边的操作数是 double 型 引起的。十二(2013/3/22遇到)if(n = 1|n = 2)f(n) = 1;D:Program FilesMicrosoft Visual StudioMyProjectsFibonacciFibonacci.cpp(7) : error C2106: = : left ope
20、rand must be l-value十三.(2013/4/15)(没解决)c1 = CWnd:GetDlgCtrlID(IDC_EDIT_NO);/获得编辑框D:Program FilesMicrosoft Visual StudioMyProjectsexeclexeclView.cpp(138) : error C2660: GetDlgCtrlID : function does not take 1 parameters十四.(2013/4/15)VC+环境下连接SQL Server数据库方法指导实验类型:设计型一、实验环境1Windows XP操作系统;2VC+6.0开发环境;3
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VC 遇到 问题
限制150内