SPM/SPM8 MEX 在 Windows 上的編譯
外觀
< SPM
SPM 華夏公益教科書已遷移至 https://www.fil.ion.ucl.ac.uk/spm/docs/ |
本頁面描述了在 Windows 7 SP1 32bit 上使用 MATLAB R2008a (7.6) 和 Microsoft Visual C++ 2005 (8.0) Express Edition 編譯 SPM8 MEX 檔案。
如果您使用其他版本的 MATLAB 和/或編譯器,請確保它們相容:支援的編譯器
下載並安裝 Microsoft Visual C++ 2005 (8.0) Express Edition。
下載並安裝 Microsoft Windows Server 2003 SP1 Platform SDK。
如果不存在名為 MSSDk 的環境變數,則需要指定它。
- 轉到 控制面板
- 轉到 系統
- 轉到 高階系統設定
- 轉到 高階
- 轉到 環境變數...
- 如果在 系統使用者變數 中沒有名為 MSSDk 的變數
- 單擊 新建...
- 然後輸入
- 變數名: MSSDk
- 變數值: C:\Program Files\Microsoft Platform SDK
從以下地址下載並安裝 MinGW
http://www.mingw.org/wiki/Getting_Started#toc1
在目錄 C:\MinGW 中,僅選擇 MinGW 開發工具包(包括 MSYS) 元件。
啟動 MATLAB 並輸入
>> mex -setup
並按照說明進行操作。
Please choose your compiler for building external interface (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\R2008a\sys\lcc\bin [2] Microsoft Visual C++ 2005 Express Edition in C:\Program Files\Microsoft Visual Studio 8 [0] None Compiler: 2 Please verify your choices: Compiler: Microsoft Visual C++ 2005 Express Edition Location: C:\Program Files\Microsoft Visual Studio 8 Are these correct [y]/n? y
如果出現錯誤訊息
Error: The Microsoft Platform Software Development Kit (SDK) was not found.
這意味著環境變數 MSSDk 設定不正確:請再次檢查上面的編譯器安裝。
如果出現警告,請不要擔心。
Warning: The MATLAB C and Fortran API has changed to support MATLAB ...
從開始選單中,選擇
- 所有程式
- Visual C++ 2005 Express Edition
- Visual Studio 工具
- Visual Studio 2005 命令提示符
- Visual Studio 工具
- Visual C++ 2005 Express Edition
然後從那裡啟動 MSYS
C:\MinGW\msys\1.0\msys.bat
使用以下命令移動到 SPM8 原始碼目錄
$ cd /c/Users/login/Documents/MATLAB/spm8/src
然後輸入以下命令開始編譯過程
$ make distclean $ make && make install $ make toolbox-distclean $ make toolbox && make toolbox-install $ make external-distclean $ make external && make external-install