VS2010配置Opencv 2.x

OpenCV中文论坛已经给出了VC 2010 Express下安装OpenCV2.4.3 http://www.opencv.org.cn/index.php/VC_2010_Express%E4%B8%8B%E5%AE%89%E8%A3%85OpenCV2.4.3 

按照要求做可以正确进行配置。

几个问题:

1、如何判断 X86 还是 X64 ?

2、Lib 和Path路径下的DLL什么关系?

3、VS 属性中 Platform ToolSet  选项v90和v100

4、注意:编译环境和发布模式的lib区别?

5、测试图像Lena.jpg 放到哪个目下? 即 VS project根目录是什么

 下面介绍在使用过程中遇到的几个问题

问题1:VS2010 在默认情况下使用V100编译,使用..\opencv\build\x86\vc9\lib 就无法正常编译通过。

【注意】debug模式用带 XXXd.lib ,release模式下用不带d的lib

解决方法:

在VS2010下,修改默认v100 ->  v90

VS2010配置Opencv 2.x_第1张图片

 

问题2:目标类型、dll和模块类型不匹配

错误提示1:

1>------ Build started: Project: project4Test, Configuration: Debug Win32 ------
1>opencv_highgui243d.lib(opencv_highgui243d.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Opencv lib,路径和lib都改成 x86\vc100对应的即可编译过去

 

错误提示2:
1>------ Build started: Project: project4Test, Configuration: Debug Win32 ------
1>Debug\project4Test.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

解决方法:

以上提示的错误,主要是要编译的目标对象类型和lib不匹配导致的

在默认情况下,创建的项目是win32的(这个就应该是module machine type ,自己猜测的),那么只能编译出X86的目标,同时必须使用X86的lib。这种情况大家不易犯错误。

在考虑编译目标类型为X64的时候:

1、首先修改target machine 为 x64 : project property page -> configuration->linker -> advanced -> Target Machine ,选择 Machine:X64

2、若提示:LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

 The problem has been solved. Many thanks to steve.
Here is the solution, for those might have the same problem :)
1. To choose the x64 platform, click Build > Configuration Manager.  Under Active Solution Platform, select In the dialog that comes up, select x64 as the new platform (it may come up by default) and then click Ok.
2. select the x64 platform in the VC window.
3. Check the Linker > Command Line property page to make sure there is no /MACHINE switch there
    3.1 if you find /MACHINE ** in the additional options window, just deletle it.
    3.2. if you find /MACHINE ** in the all options window, go to the Linker > Advanced property page and make sure that   Target Machine is "Not Set".
lan
【上述内容摘抄在网络,地址....】

 3、注意linker的lib目录、input对应x64的lib及目录

 

你可能感兴趣的:(OpenCV,VS2010,OpenCV,VS2010)