转自 http://mlinking.blog.163.com/blog/static/185801922201331464626365/
因为要完成 CBIR 的项目, 就需要使用相应的图像处理的算法, 简便的方法当然就是使用其他学者实现里的代码, 当然就离不开 Matlab. 而且, 其中的一个代码还需要 Matlab + C++ 混合 – http://www.robots./~vgg/software/SelfSimilarity/.
------------------------------------------------------ * C++ Implementation of the Self-Similarity Descriptor * Version 1.1.1 * * Author: Ken Chatfield, March 2009 * ken@robots. * http://www.robots./~ken ------------------------------------------------------
可是, 按照学者提供的 readme.txt 中 "4. Usage of MEX Wrapper" 的提示, 当在 Matlab R2012a (V7.14.0.739) 中输入 ">> mex mexCalcSsdescs.cc ssdesc.cc" 尝试完成 Matlab 的 Wrapper 时, 遇到了后来知晓非常普遍的问题:
>> mex mexCalcSsdescs.cc ssdesc.cc Error: Could not detect a compiler on local system which can compile the specified input file(s) Error using mex (line 206) Unable to complete successfully.
看返回的错误信息, 知晓就是没有合适的编译器.
通过阅读网上的文档, 知晓 Matlab 有自带的编译器 LCC, 可是, 尝试一番后结论是不适用.
>> mex -setup
Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see http://www./support/compilers/R2012a/win32.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2012a\sys\lcc
[0] None
Compiler: 1
Please verify your choices:
Compiler: Lcc-win32 C 2.4.1 Location: C:\PROGRA~1\MATLAB\R2012a\sys\lcc
Are these correct [y]/n? y
Trying to update options file: C:\Users\mlinking\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2012a\bin\win32\mexopts\lccopts.bat
Done . . .
************************************************************************** Warning: The MATLAB C and Fortran API has changed to support MATLAB variables with more than 2^32-1 elements. In the near future you will be required to update your code to utilize the new API. You can find more information about this at: http://www./help/techdoc/matlab_external/bsflnue-1.html Building with the -largeArrayDims option enables the new API. **************************************************************************
有一堆的问题:
>> mex mexCalcSsdescs.cc ssdesc.cc lcc preprocessor error: mexCalcSsdescs.cc:25 Could not find include file <algorithm> lcc preprocessor error: mexCalcSsdescs.cc:26 Could not find include file <limits> lcc preprocessor error: mexCalcSsdescs.cc:27 Could not find include file <vector> lcc preprocessor error: mexCalcSsdescs.cc:28 Could not find include file <list> lcc preprocessor error: mexCalcSsdescs.cc:30 Could not find include file <cassert> lcc preprocessor error: mexCalcSsdescs.cc:31 Could not find include file <cmath> lcc preprocessor error: mexCalcSsdescs.cc:32 Could not find include file <cstdio> lcc preprocessor error: mexCalcSsdescs.cc:33 Could not find include file <cstdlib> lcc preprocessor error: .\ssdesc.h:45 mexCalcSsdescs.cc:36 Could not find include file <algorithm> lcc preprocessor error: .\ssdesc.h:46 mexCalcSsdescs.cc:36 Could not find include file <limits> lcc preprocessor error: .\ssdesc.h:47 mexCalcSsdescs.cc:36 Could not find include file <vector> lcc preprocessor error: .\ssdesc.h:48 mexCalcSsdescs.cc:36 Could not find include file <list> lcc preprocessor error: .\ssdesc.h:50 mexCalcSsdescs.cc:36 Could not find include file <cassert> lcc preprocessor error: .\ssdesc.h:51 mexCalcSsdescs.cc:36 Could not find include file <cmath> lcc preprocessor error: .\ssdesc.h:52 mexCalcSsdescs.cc:36 Could not find include file <cstdio> lcc preprocessor error: .\ssdesc.h:53 mexCalcSsdescs.cc:36 Could not find include file <cstdlib> Error mexCalcSsdescs.cc: .\ssdesc.h: 51 syntax error; found `namespace' expecting `;' Error mexCalcSsdescs.cc: .\ssdesc.h: 51 syntax error; found `std' expecting `;' Error mexCalcSsdescs.cc: .\ssdesc.h: 53 syntax error; found `ssdesc' expecting `;' Error mexCalcSsdescs.cc: .\ssdesc.h: 54 syntax error; found `{' expecting `;' Error mexCalcSsdescs.cc: .\ssdesc.h: 54 too many errors
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of 'mexCalcSsdescs.cc' failed.
Error using mex (line 206) Unable to complete successfully.
应该还是编译器不匹配的问题. 在 Google 中输入 "windows mex Unable to complete successfully", 前两条就点出来问题所在:
http://blog.csdn.net/rodmanwu/article/details/6846190
2011-10-09 15:59
问题: 继续还是那套MATLAB代码点击打开链接 使用里面complie.m编译时出现一下错误提示: [plain] view plaincopyprint
在MATLAB 7.8 (R2009a)及之后的版本,就会支持-largeArrayDims
解决方法:mathworks给出的方案
按照上面提示的 Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 的地址下载对应的光盘映像文件 - GRMSDK_EN_DVD.iso, 然后进行安装:
默认安装后, 在 Programs 目录下新增了三个文件夹:
因为上博文中叙述与我的环境不同, 并不不清楚 – "选项中选择支持: Visual C++ 9.0 Compilers. These compilers allow you to target x86, x64, IA64 processor architectures.", 所以, 不知道要怎么选项:
>> mex -setup
Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see http://www./support/compilers/R2012a/win32.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? n
Select a compiler: [1] Intel C++ 12.0 (with Microsoft Software Development Kit (SDK) linker) [2] Intel C++ 12.0 (with Microsoft Visual C++ 2008 SP1 linker) [3] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker) [4] Intel C++ 11.1 (with Microsoft Visual C++ 2008 SP1 linker) [5] Intel Visual Fortran 12 (with Microsoft Software Development Kit (SDK) linker) [6] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 SP1 linker) [7] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 Shell linker) [8] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2010 linker) [9] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker) [10] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker) [11] Lcc-win32 C 2.4.1 [12] Microsoft Software Development Kit (SDK) 7.1 [13] Microsoft Visual C++ 2005 SP1 [14] Microsoft Visual C++ 2008 SP1 [15] Microsoft Visual C++ 2010 [16] Open WATCOM C++
[0] None
根据上面的信息, 显然需要选择 [12]:
Compiler: 12
Warning: The default location for Microsoft Software Development Kit (SDK) compiler is: "C:\Program Files\Microsoft Visual Studio 10.0" but either that directory does not exist or the configuration is invalid.
Use C:\Program Files\Microsoft Visual Studio 10.0 anyway [y]/n? n Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio 10.0] C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin
首先显示的警告信息意思是默认地 matlab 找不到 "C:\Program Files\Microsoft Visual Studio 10.0"的位置 – 要注意这里的 "10.0" 信息, 后面启发我解决此问题时会用到. 我在这里做的就是按照自己的理解设定我认为的 SDK 的目录 – "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin", 可惜, 不成功!
Please verify your choices:
Compiler: Microsoft Software Development Kit (SDK) 7.1 Location: C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin
Are these correct [y]/n? y
***************************************************************************** Error: A part of the Microsoft Windows Software Development Kit (SDK) cannot be found. Please consider reinstalling while paying special attention to all the install screens. Be sure to install the .NET Framework. *****************************************************************************
Error using mex (line 206) Unable to complete successfully.
那么, 我自然会想到尝试其他两个目录, 可是仍然不成功!
Use C:\Program Files\Microsoft Visual Studio 10.0 anyway [y]/n? n Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio 10.0] 'C:\Program Files\Microsoft Visual Studio 9.0'
Please verify your choices:
Compiler: Microsoft Software Development Kit (SDK) 7.1 Location: 'C:\Program Files\Microsoft Visual Studio 9.0'
Are these correct [y]/n? y
***************************************************************************** Error: A part of the Microsoft Windows Software Development Kit (SDK) cannot be found. Please consider reinstalling while paying special attention to all the install screens. Be sure to install the .NET Framework. *****************************************************************************
Error using mex (line 206) Unable to complete successfully.
那么, 你们也就知道我接下来要做的 – 还是回到 Google 里寻找. 期间也发现了 "mbuild - setup"的指令, 虽然提示信息不同, 但是, 其本质与上面的 "mex - setup" 是一样的.
>> mbuild -setup
Welcome to mbuild -setup. This utility will help you set up a default compiler. For a list of supported compilers, see http://www./support/compilers/R2012a/win32.html
Please choose your compiler for building shared libraries or COM components:
Would you like mbuild to locate installed compilers [y]/n? n
Select a compiler: [1] Lcc-win32 C 2.4.1 [2] Microsoft Software Development Kit (SDK) 7.1 [3] Microsoft Visual C++ 6.0 [4] Microsoft Visual C++ 2005 SP1 [5] Microsoft Visual C++ 2008 SP1 [6] Microsoft Visual C++ 2010
[0] None
Compiler: 5
Warning: The default location for Microsoft Visual C++ 2008 SP1 compiler is: "C:\Program Files\Microsoft Visual Studio 9.0" but either that directory does not exist or the configuration is invalid.
Use C:\Program Files\Microsoft Visual Studio 9.0 anyway [y]/n?
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 SP1 Location: C:\Program Files\Microsoft Visual Studio 9.0
Are these correct [y]/n?
**************************************************************************** Warning: Applications/components generated using Microsoft Visual Studio 2008 require that the Microsoft Visual Studio 2008 run-time libraries be available on the computer used for deployment. To redistribute your applications/components, be sure that the deployment machine has these run-time libraries. ****************************************************************************
Trying to update options file: C:\Users\mlinking\AppData\Roaming\MathWorks\MATLAB\R2012a\compopts.bat From template: C:\PROGRA~1\MATLAB\R2012a\bin\win32\mbuildopts\msvc90compp.bat
Done . . .
>> mex mexCalcSsdescs.cc ssdesc.cc
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: 'mexCalcSsdescs.cc' not found.
Error using mex (line 206) Unable to complete successfully.
>> mex mexCalcSsdescs.cc ssdesc.cc lcc preprocessor error: mexCalcSsdescs.cc:25 Could not find include file <algorithm> lcc preprocessor error: mexCalcSsdescs.cc:26 Could not find include file <limits> lcc preprocessor error: mexCalcSsdescs.cc:27 Could not find include file <vector> lcc preprocessor error: mexCalcSsdescs.cc:28 Could not find include file <list> lcc preprocessor error: mexCalcSsdescs.cc:30 Could not find include file <cassert> lcc preprocessor error: mexCalcSsdescs.cc:31 Could not find include file <cmath> lcc preprocessor error: mexCalcSsdescs.cc:32 Could not find include file <cstdio> lcc preprocessor error: mexCalcSsdescs.cc:33 Could not find include file <cstdlib> lcc preprocessor error: .\ssdesc.h:45 mexCalcSsdescs.cc:36 Could not find include file <algorithm> lcc preprocessor error: .\ssdesc.h:46 mexCalcSsdescs.cc:36 Could not find include file <limits> lcc preprocessor error: .\ssdesc.h:47 mexCalcSsdescs.cc:36 Could not find include file <vector> lcc preprocessor error: .\ssdesc.h:48 mexCalcSsdescs.cc:36 Could not find include file <list> lcc preprocessor error: .\ssdesc.h:50 mexCalcSsdescs.cc:36 Could not find include file <cassert> lcc preprocessor error: .\ssdesc.h:51 mexCalcSsdescs.cc:36 Could not find include file <cmath> lcc preprocessor error: .\ssdesc.h:52 mexCalcSsdescs.cc:36 Could not find include file <cstdio> lcc preprocessor error: .\ssdesc.h:53 mexCalcSsdescs.cc:36 Could not find include file <cstdlib> Error mexCalcSsdescs.cc: .\ssdesc.h: 51 syntax error; found `namespace' expecting `;' Error mexCalcSsdescs.cc: .\ssdesc.h: 51 syntax error; found `std' expecting `;' Error mexCalcSsdescs.cc: .\ssdesc.h: 53 syntax error; found `ssdesc' expecting `;' Error mexCalcSsdescs.cc: .\ssdesc.h: 54 syntax error; found `{' expecting `;' Error mexCalcSsdescs.cc: .\ssdesc.h: 54 too many errors
C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of 'mexCalcSsdescs.cc' failed.
Error using mex (line 206) Unable to complete successfully.
再看了一些网页后, 想着会否跟版本有关? 即 Matlab 2012a 支持的编译器版本是固定好了的, 那么, 选择时就最好选择相应的版本? 在前面已经尝试了选择 "[12] Microsoft Software Development Kit (SDK) 7.1" 来对应那三个目录, 也都没有成功, 是否应该选择对应 "Microsoft Visual Studio 9.0" 的Matlab 2012a选项? 在网上看, 正好 "[14] Microsoft Visual C++ 2008 SP1" 默认对应的就是 "Microsoft Visual Studio 9.0". 试了一下, 果然成功!
>> mex -setup
Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see http://www./support/compilers/R2012a/win32.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? n
Select a compiler: [1] Intel C++ 12.0 (with Microsoft Software Development Kit (SDK) linker) [2] Intel C++ 12.0 (with Microsoft Visual C++ 2008 SP1 linker) [3] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker) [4] Intel C++ 11.1 (with Microsoft Visual C++ 2008 SP1 linker) [5] Intel Visual Fortran 12 (with Microsoft Software Development Kit (SDK) linker) [6] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 SP1 linker) [7] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 Shell linker) [8] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2010 linker) [9] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker) [10] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker) [11] Lcc-win32 C 2.4.1 [12] Microsoft Software Development Kit (SDK) 7.1 [13] Microsoft Visual C++ 2005 SP1 [14] Microsoft Visual C++ 2008 SP1 [15] Microsoft Visual C++ 2010 [16] Open WATCOM C++
[0] None
Compiler: 14
Warning: The default location for Microsoft Visual C++ 2008 SP1 compiler is: "C:\Program Files\Microsoft Visual Studio 9.0" but either that directory does not exist or the configuration is invalid.
Use C:\Program Files\Microsoft Visual Studio 9.0 anyway [y]/n?
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 SP1 Location: C:\Program Files\Microsoft Visual Studio 9.0
Are these correct [y]/n?
*************************************************************************** Warning: MEX-files generated using Microsoft Visual C++ 2008 require that Microsoft Visual Studio 2008 run-time libraries be available on the computer they are run on. If you plan to redistribute your MEX-files to other MATLAB users, be sure that they have the run-time libraries. ***************************************************************************
Trying to update options file: C:\Users\mlinking\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2012a\bin\win32\mexopts\msvc90opts.bat
Done . . .
************************************************************************** Warning: The MATLAB C and Fortran API has changed to support MATLAB variables with more than 2^32-1 elements. In the near future you will be required to update your code to utilize the new API. You can find more information about this at: http://www./help/techdoc/matlab_external/bsflnue-1.html Building with the -largeArrayDims option enables the new API. **************************************************************************
编译也就成功了:
>> mex mexCalcSsdescs.cc ssdesc.cc
输入上述指令, 没有任何信息反馈 – 也就意味着成功!
记之!
|
|