怎么解决这种编译错误啊
严重崩溃了,最近连连遇到这种错误。
Linking...
error LNK2001: unresolved external symbol "int g_bChinese " (?g_bChinese@@3HA)
。。。
symbol 后面从 类成员函数 到 全局变量 全被我遇上了,冤~求助~~
还有那#include的问题,#include来来去去竟然还说某某类型未定义。。。汗
[解决办法]
这种link错误一般是没有包含对应的lib文件,或者是没有将相应的cpp文件添加到工程中.
[解决办法]
int g_bChinese这个变量是在哪里定义的?使用的时候有没有extern
[解决办法]
全工程搜索g_bChinese变量。
[解决办法]
在cpp中加入:
int g_bChinese = 0;
在h中加入:
extern int g_bChinese;
[解决办法]
数据初始化,
成员函数话确认已实现,或未实的未经调用
[解决办法]
晕晕。。
[解决办法]
baidu一下,我以前遇到过,CSDN的BLOG里有很多人专门研究过这个连接错误
[解决办法]
字面上来理解 就是说 不认识 标志符 "int g_bChinese "
又是一个全局变量 初识者通常会认为 既然是个全局变量 那就哪里都可以看得到它
实际上 应该把int g_bChinese 定义再ccp文件中 然后 在对应的h 声明 extern int g_bChinese; 然后再要用的地方 include ".h " 才可以
[解决办法]
LNK2001: unresolved external symbol __endthreadex
LNK2001: unresolved external symbol __beginthreadex
These errors result from using an MFC object or function without telling the link editor to search the MFC libraries.
Go to Project --> Settings (Build --> Settings ). On the General tab check the box that says "Use MFC in a Shared DLL ".
--------------------------------------------
LNK2001: unresolved external symbol _main
Your project doesn 't contain a function called main(). The error usually results from forgeting to add main.cpp to the project workspace.
--------------------------------------------
<File> .obj : error LNK2001: unresolved external symbol "public: void __thiscall <Class1> :: <Function1> ( <Type> ) "
This a generic form of a LNK2001 error where <File> .obj can be any object file in your project and <Class1> :: <Function1> ( <Type> ) can be any function in any class. Substitute the specific <File> , <Class> , <Function> , and <Type> in your message into the instructions below to diagnose and correct the problem.
An LNK2001 error means that the link editor is looking for a compiled function and can 't find it. The call to the "missing function " is somewhere in <File> .cpp. Unfortunately, double-clicking on the error message won 't take you to the point in <File.cpp> where the function is called but you can search for it with Find or Find In Files. The function the link editor can 't find is a member of <Class> , its name is <Function1> , and its return type is <Type> .
There are two common reasons for a LNK2001 error:
The call in <File> .cpp doesn 't match the function prototype in <Class> .h and/or the implementation in <Class> .cpp. The mismatch may be in the function name, return type, or number and/or type of parameters. Correction strategies include:
Check that the function name is spelled the same (case sensitive) in all three files (File.cpp, Class.h, and Class.cpp).
Check that the function is actually declared and defined within <Class> - perhaps you defined it as a member of a different class or perhaps you tried to call the function (in <File> .cpp) using an object or object pointer of a different class.
Check that the number and type of parameters in the function implementation (in <Class> .cpp) matches the number and type of parameters declared in the function declaration in <Class> .h.
Check that the number and type of parameters in the function call (in <File> .cpp) matches the number and type of parameters declared in the function header in <Class> .cpp.
The function was never declared or was declared but never defined. To see if either is the case go to the ClassView window of the Workspace view. Click the + next to <Class> and find <Function> in the list of member functions.
If <Function> is NOT in the list then it was never declared or defined - add a declaration to the class declaraion in <Class> .h and implement the function in <Class> .cpp.
If <Function> is in the list then right click on it and select Go To Definition from the pop-up menu. If you get the error message Cannot find definition (implementation) of this function then the function was declared but never defined (implemented). Implement the function to <Class> .cpp.
--------------------------------------------
[解决办法]
一同学习