轉(zhuǎn)自 http://mlinking.blog.163.com/blog/static/185801922201331464626365/
因?yàn)橐瓿?CBIR 的項(xiàng)目, 就需要使用相應(yīng)的圖像處理的算法, 簡(jiǎn)便的方法當(dāng)然就是使用其他學(xué)者實(shí)現(xiàn)里的代碼, 當(dāng)然就離不開(kāi) Matlab. 而且, 其中的一個(gè)代碼還需要 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 ------------------------------------------------------
可是, 按照學(xué)者提供的 readme.txt 中 "4. Usage of MEX Wrapper" 的提示, 當(dāng)在 Matlab R2012a (V7.14.0.739) 中輸入 ">> mex mexCalcSsdescs.cc ssdesc.cc" 嘗試完成 Matlab 的 Wrapper 時(shí), 遇到了后來(lái)知曉非常普遍的問(wèn)題:
>> 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.
看返回的錯(cuò)誤信息, 知曉就是沒(méi)有合適的編譯器.
通過(guò)閱讀網(wǎng)上的文檔, 知曉 Matlab 有自帶的編譯器 LCC, 可是, 嘗試一番后結(jié)論是不適用.
>> 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. **************************************************************************
有一堆的問(wèn)題:
>> 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.
應(yīng)該還是編譯器不匹配的問(wèn)題. 在 Google 中輸入 "windows mex Unable to complete successfully", 前兩條就點(diǎn)出來(lái)問(wèn)題所在:
http://blog.csdn.net/rodmanwu/article/details/6846190
2011-10-09 15:59
問(wèn)題: 繼續(xù)還是那套MATLAB代碼點(diǎn)擊打開(kāi)鏈接 使用里面complie.m編譯時(shí)出現(xiàn)一下錯(cuò)誤提示: [plain] view plaincopyprint
在MATLAB 7.8 (R2009a)及之后的版本,就會(huì)支持-largeArrayDims
解決方法:mathworks給出的方案
按照上面提示的 Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 的地址下載對(duì)應(yīng)的光盤(pán)映像文件 - GRMSDK_EN_DVD.iso, 然后進(jìn)行安裝:
默認(rèn)安裝后, 在 Programs 目錄下新增了三個(gè)文件夾:
因?yàn)樯喜┪闹袛⑹雠c我的環(huán)境不同, 并不不清楚 – "選項(xiàng)中選擇支持: Visual C++ 9.0 Compilers. These compilers allow you to target x86, x64, IA64 processor architectures.", 所以, 不知道要怎么選項(xiàng):
>> 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
根據(jù)上面的信息, 顯然需要選擇 [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
首先顯示的警告信息意思是默認(rèn)地 matlab 找不到 "C:\Program Files\Microsoft Visual Studio 10.0"的位置 – 要注意這里的 "10.0" 信息, 后面啟發(fā)我解決此問(wèn)題時(shí)會(huì)用到. 我在這里做的就是按照自己的理解設(shè)定我認(rèn)為的 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.
那么, 我自然會(huì)想到嘗試其他兩個(gè)目錄, 可是仍然不成功!
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.
那么, 你們也就知道我接下來(lái)要做的 – 還是回到 Google 里尋找. 期間也發(fā)現(xiàn)了 "mbuild - setup"的指令, 雖然提示信息不同, 但是, 其本質(zhì)與上面的 "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.
再看了一些網(wǎng)頁(yè)后, 想著會(huì)否跟版本有關(guān)? 即 Matlab 2012a 支持的編譯器版本是固定好了的, 那么, 選擇時(shí)就最好選擇相應(yīng)的版本? 在前面已經(jīng)嘗試了選擇 "[12] Microsoft Software Development Kit (SDK) 7.1" 來(lái)對(duì)應(yīng)那三個(gè)目錄, 也都沒(méi)有成功, 是否應(yīng)該選擇對(duì)應(yīng) "Microsoft Visual Studio 9.0" 的Matlab 2012a選項(xiàng)? 在網(wǎng)上看, 正好 "[14] Microsoft Visual C++ 2008 SP1" 默認(rèn)對(duì)應(yīng)的就是 "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
輸入上述指令, 沒(méi)有任何信息反饋 – 也就意味著成功!
記之!
|
|