When a function is declared in the header file but is not defined in the corresponding source file, an unresolved external symbol error occurs. In addition, when a function calls a function in an external library file but does not include the dependent library file in the properties of the current project, this error also occurs.
In summary, when a solution cannot find the definition of the involved function in linking, the "unresolved external symbol" error will occur.
For example, the following is a link error caused by the absence of mil. Lib.
1> linking...
1> mdispselect. OBJ: Error lnk2019: unresolved external symbol _ mappfree @ 4 referenced in function _ main
1> mdispselect. OBJ: Error lnk2019: unresolved external symbol _ msysfree @ 4 referenced in function _ main
1> mdispselect. OBJ: Error lnk2019: unresolved external symbol _ mdispfree @ 4 referenced in function _ main
[Solution]
1. Project-> ** properties...-> Configuration properties-> linker-> input-> additional dependencies-> mil. Lib
In addition, you also need to add the corresponding directory of the Mil library before: tools-> options-> projects and solutions-> VC ++ directories-> show directories for-> Add C: \ Program Files \ matrox imaging \ mil \ include and tools-> options-> projects and solutions-> VC ++ directories-> show directories for-> Add C: \ Program Files \ matrox imaging \ mil \ Lib. The purpose of adding a directory is to make Vc do not always use an absolute address when calling the corresponding library file. VC can search by file name in the contained directory. In this way, the previous mil. Lib does not need to use an absolute address.
[Disadvantage] Poor portability. If you copy the source and header files in the original project and re-create the project (for example, a program found on an e-book or on the Internet ), you still need to add directories and required library files in the project.
2. Add # pragma comment (Lib, "mil. lib") before the program to achieve the same effect.
[Advantage] avoids problems in solution 1.