一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

Matlab MEX on Win7 with SDK 7.1

 好景宜人 2015-04-03

轉(zhuǎn)自 http://mlinking.blog.163.com/blog/static/185801922201331464626365/

 

  1. 事起

因?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)有合適的編譯器.

 

  1. 方案

    1. Matlab 自帶的編譯器

通過(guò)閱讀網(wǎng)上的文檔, 知曉 Matlab 有自帶的編譯器 LCC, 可是, 嘗試一番后結(jié)論是不適用.

      1. "mex -setup" 進(jìn)行設(shè)置

>> 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.

**************************************************************************

  1. ">> mex mexCalcSsdescs.cc ssdesc.cc" 編譯

有一堆的問(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.

 

  1. Matlab + Windows編譯器

應(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

 

    1. (網(wǎng)頁(yè)) 解決在WIN7(64位)上Mex無(wú)法編譯的問(wèn)題

2011-10-09 15:59

 

問(wèn)題:

繼續(xù)還是那套MATLAB代碼點(diǎn)擊打開(kāi)鏈接

使用里面complie.m編譯時(shí)出現(xiàn)一下錯(cuò)誤提示:

[plain] view plaincopyprint

  1. **************************************************************************   
  2.   Warning: The MATLAB C and Fortran API has changed to support MATLAB   
  3.            variables with more than 2^32-1 elements.  In the near future   
  4.            you will be required to update your code to utilize the new   
  5.            API. You can find more information about this at:   
  6.            http://www./support/solutions/data/1-5C27B9.html?solution=1-5C27B9   
  7.            Building with the -largeArrayDims option enables the new API.   
  8. **************************************************************************   
  9.    
  10. >> COMPILE  
  11. Compiling Normalization  
  12.    
  13.   D:\PROGRA~2\MATLAB\R2008A\BIN\MEX.PL: Error: Compile of 'mxNormalize.cpp' failed.   
  14.    
  15.  Error using ==> mex at 207  
  16. Unable to complete successfully.  


查了很久,發(fā)現(xiàn)是編譯器的問(wèn)題。

在MATLAB 7.8 (R2009a)及之后的版本,就會(huì)支持-largeArrayDims

 

解決方法mathworks給出的方案

  1. 安裝 Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1".(下載地址
  2. 選項(xiàng)中選擇支持: Visual C++ 9.0 Compilers. These compilers allow you to target x86, x64, IA64 processor architectures."
  3. 看看有沒(méi)這個(gè)文件 C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\cl.exe。有就應(yīng)該支持64位了。
  1. 我失敗的實(shí)踐

    1. Windows SDK for Windows 7的安裝

按照上面提示的 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è)文件夾:

  1. 失敗的嘗試 (1)

因?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.

 

  1. 失敗的嘗試 (2)

那么, 我自然會(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.

 

  1. 失敗的嘗試 (3)

那么, 你們也就知道我接下來(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.

 

  1. 版本?

再看了一些網(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)有任何信息反饋 – 也就意味著成功!

 

記之!

  

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多

    91人妻人澡人人爽人人精品| 国产一区国产二区在线视频| 午夜精品麻豆视频91| 亚洲男人的天堂色偷偷| 91偷拍与自偷拍精品| 国产福利一区二区久久| 五月天六月激情联盟网| 亚洲精品欧美精品一区三区| 国产精品久久男人的天堂| 国产精品一级香蕉一区| 中文字幕日韩精品人一妻| 麻豆印象传媒在线观看| 肥白女人日韩中文视频| 欧美午夜一级艳片免费看| 国产精品久久香蕉国产线| 少妇熟女亚洲色图av天堂| 欧美成人精品一区二区久久| 久久久精品日韩欧美丰满| 欧美又黑又粗大又硬又爽| 久久亚洲成熟女人毛片| 韩日黄片在线免费观看| 人妻亚洲一区二区三区| 亚洲一区二区亚洲日本| 91亚洲国产成人久久| 国产成人午夜福利片片| 丝袜破了有美女肉体免费观看| 国产一级内射麻豆91| 久久久精品日韩欧美丰满| 空之色水之色在线播放| 91日韩欧美国产视频| 国产传媒一区二区三区| 久久精品国产99精品最新| 草草视频福利在线观看| 午夜精品久久久99热连载| 亚洲国产日韩欧美三级| 欧美日韩国内一区二区| 欧美整片精品日韩综合| 亚洲欧美天堂精品在线| 在线观看免费视频你懂的| 日韩人妻一区二区欧美| 精品伊人久久大香线蕉综合|