Recently in the development with VS 2008, beginners encounter a lot of problems, one of the most headache is: LNK2019.
Baidu is not enough to talk about the comprehensive, anyway, did not solve my problem.
Error LNK2019 problem in VC 6.0 is Error lnk2001:unresolved external symbol problem, may be wrong number changed.
A similar error occurred at compile time: Dlgcode.obj:error LNK2019: unresolved external symbol _readregmark, which is referenced in the function [email protected]. The essence of this error is that the linker cannot find the function definition in the compiled obj, lib, or DLL file.
1, this is Baidu found the method: Http://jingyan.baidu.com/article/4d58d54135d7a79dd4e9c0ad.html. There is a header file (with a function declaration) but no LIB. Usually appears when you use a third-party provided library, downloaded the header file but forgot to download the library file, or the library file forgot to put in the corresponding directory.
2, you write the function declaration of the header file also wrote the function definition of CPP file, but still appear LNK2019 error. Possible reasons: Forgot to add these two files to the project. It typically appears in the hybrid development process with Visual Studio and Notepad (or ultraedit) that you include the appropriate header files with Notepad, but forget to add them to the project in Visual Studio. May also appear in the development process of the solution, in a project under the solution to join them but forget to join in other projects, I have only exposure to VC 6 and VS 2008, in the middle of years not to use the new version vs, to 2008 suddenly find out how a "solution", "solution" The following can also put a lot of projects, so often in a project to write the shared source code, but forget to add them in other projects. The problem is similar to the 1th one, except that the library is provided by you, but it is not given to VS 2008 compiled.
3, you write the function declaration of the header file also wrote the function definition of the CPP file also joined the project and you are sure that the function body is definitely in this library file, but still appear LNK2019 error. Possible reasons: C and C + + language mixed, because C + + support function overloading so the C + + compiler generated by the library file function name will be unrecognizable, such as the C compiler will generate _readregmark this function name, and C + + compiler generated "void __cdecl Readregmark (char *) "([email protected]@[email protected]) such a function name. When your function is written in C, the VS compiler will be compiled according to the C language rules, but the linker does not know that it is silly to use the C + + rules of the function name to find the results can not be found, and you are sure TM is not in this library you a blind. Workaround: Add the header file in the C language
#ifdef __cplusplus extern " C " {#endifvoid readregmark (char *regmark); // write the function declaration here #ifdef __cplusplus} #endif
Give the linker a hint that this function is C language, do not look for the wrong TM.
4, this is my Baidu came, let's put in. http://blog.csdn.net/jtop0/article/details/5779782. The template declaration and implementation are placed in the same folder.
5, also Baidu came. Http://www.programlife.net/error-lnk2019.html. Inline functions are defined in the header file.
6, Baidu's. Http://jingyan.baidu.com/article/d621e8da0d7c022864913f40.html. Caused by the wrong project type.
7, there seems to be a difference. Http://www.douban.com/note/65638800/.
Analysis of "error LNK2019: unresolved external symbols"