After learning openCV, I tried to run the online routine on the local machine and encountered various problems, so I recorded them for reference.
For VS2008, multiple projects can be created in one solution, but the unpleasant thing is that --
1. Processing of wide bytes
Modify project properties-> Configure properties-> in general, the "Character Set" option defaults to "use UNICODE Character Set", and each project must be manually changed to "use multi-Byte Character Set"
2. Additional linker dependencies (external Library)
You need to manually add cv200d. lib highgui200d. lib cxcore200d. lib to manually set properties for each project-> connector-> Add dependencies "Debug" and "Release ".
Note: The file name of the library to be added must be consistent with that of the openCV library generated by the local compiler. If openCV has been updated to version 3.15, the library generated after Cmake compilation may be cv315d. lib, depending on the local situation.
The dependency configuration ensures that the debug version and binary code of opencv are automatically re-compiled when the source code is changed.
For the "fatal error C1020: Unexpected # endif" error, the cause is roughly as follows:
If the Pre-compiled header is used, VC will search
# Include "stdafx. h"
Before this line of code is found, VC ignores all the code.
That is to say, in the following example, VC finds the second line # include "stdafx. h ", the first line # ifndef _ EiC is ignored, so" unexpected # endif "cannot be found.
# Ifndef _ EiC
# Include "stdafx. h"
# Include "cv. h"
# Include "cxcore. h"
# Include "highgui. h"
# Endif
Modify the preceding example as follows.
# Include "stdafx. h"
# Ifndef _ EiC
# Include "cv. h"
# Include "cxcore. h"
# Include "highgui. h"
# Endif
PS.: # ifndef V. S. # ifdef
# Ifndef avoid repeated compilation of multiple identical header files during compilation and avoid conflicts.
PPS .:
The first statement of all CPP implementation files is: # include "stdafx. h"
Because the compiler believes that,All the code before the command # include "stdafx. h" is pre-compiled.It skips the # include "stdafx. h" command and uses projectname. pch to compile all the code after this command.