在matlab2008a下对c 进行编译,出现一系列的变量不能识别问题,然后百度,把头文件提前,编译仍然通不过,此刻才发现microsoft visio2008 已经不能使用(无法读C代码),到控制面板下更改却不能升级,气急败坏下直接卸载以及一系列的SDK2005和2010。百度安装文件,下载,再安装(3个小时过去了)。
又一轮
%%%%%%%%%%%%%%%%
>> 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:
[0] None
Compiler: 0
mex: No compiler selected. No action taken.
%%%%%%%%%%%%%%%%%
>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? n
Select a compiler:
[1] Intel C++ 9.1 (with Microsoft Visual C++ 2005 linker)
[2] Intel Visual Fortran 10.1 (with Microsoft Visual C++ 2005 linker)
[3] Intel Visual Fortran 9.1 (with Microsoft Visual C++ 2005 linker)
[4] Microsoft Platform SDK 14.0
[5] Microsoft Visual C++ 2005
[6] Microsoft Visual C++ 2008
[0] None
Compiler: 6
The default location for Microsoft Visual C++ 2008 compilers is C:\Program Files (x86)\Microsoft Visual Studio 9.0,
but that directory does not exist on this machine.
Use C:\Program Files (x86)\Microsoft Visual Studio 9.0 anyway [y]/n? n
Please enter the location of your compiler: [C:\Program Files (x86)\Microsoft Visual Studio 9.0] D:\Program Files (x86)\Microsoft Visual Studio 9.0D
Please verify your choices:
Compiler: Microsoft Visual C++ 2008
Location: D:\Program Files (x86)\Microsoft Visual Studio 9.0D
Are these correct [y]/n? y
***************************************************************************
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\user\AppData\Roaming\MathWorks\MATLAB\R2008a\mexopts.bat
From template: D:\PROGRA~2\MATLAB\R2008a\bin\win64\mexopts\msvc90opts.bat
Done . . .
忽略warning,再调试,问题更大,编译直接通不过。
>> cd E:\phd_thesis\code\colocalize-v1\colocalize-v1\ext\objectness-release-v2.2\MEX
>> mex computeIntegralHistogramMex.c
Error: Could not find the compiler "cl" on the DOS path.
Use mex -setup to configure your environment properly.
D:\PROGRA~2\MATLAB\R2008A\BIN\MEX.PL: Error: Unable to locate compiler.
??? Error using ==> mex at 207
Unable to complete successfully.
>> cd
D:\Program Files\MATLAB\R2008a\extern\examples
>> mex yprime.c
D:\PROGRA~2\MATLAB\R2008A\BIN\MEX.PL: Error: 'yprime.c' not found.
??? Error using ==> mex at 207
Unable to complete successfully.
>> mex yprime.c
D:\PROGRA~2\MATLAB\R2008A\BIN\MEX.PL: Error: Compile of 'yprime.c' failed.
安装的visual studio 2008 不能编译,给定的例子都通不过,还是怀疑compiler。太不给力了,你说急人不急人! 卸载之前的2010的SDK还可以进行调试,卸载之后直接罢工。想以前装的时候也是费了很大的力才得以正常工作........
新的一天又开始,还得在这里下功夫,装个可以用的编译器还真不简单,怪不得我那么讨厌重装系统!
继续搞visual studio 2008,光装了不行,还必须得升级。于是乎重新搜索studio的升级方案,发现要一个crackvs2008forwindows7软件。
在优快云里下载的crackvs2008forwindows7软件,点击“Bug 微软”,即在“VS2008的安装卸载程序”维护界面下方出现序列号填写框,填入序列号“PYHYP-WXB3B-B2CCM-V9DX9-VDY8T”,升级成功。
一上午过去,果断卸载VS2008。重新自定义安装,默认路径,VC++选项下有X64编译,勾选,重装......
>> 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] Microsoft Visual C++ 2008 in C:\Program Files (x86)\Microsoft Visual Studio 9.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2008
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0
Are these correct [y]/n? y
***************************************************************************
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\user\AppData\Roaming\MathWorks\MATLAB\R2008a\mexopts.bat
From template: D:\PROGRA~2\MATLAB\R2008a\bin\win64\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.mathworks.com/support/solutions/data/1-5C27B9.html?solution=1-5C27B9
Building with the -largeArrayDims option enables the new API.
**************************************************************************
>> cd
C:\Users\user\Documents\MATLAB
>> cd D:\Program Files\MATLAB\R2008a\extern\examples\mex
??? Error using ==> cd
Too many input arguments.
>> mex yprime.c
>>
果断搞定!
总结:最最难搞的就是没有编译器,主要是因为默认安装的时候vc++下没有打钩C copliler这个选项,所以一大圈又一大圈的绕回来.......
附:如果编译的时候遇到问题,比如error C2065: “n”: 未声明的标识符 等问题,这类问题主要还是在C程序中,变量的声明要放在执行程序的最前面,所以应该自己主动去看
代码,然后把相应的变量声明放在最前面。对于是不是头文件遗失,还是要先把变量放对位置之后运行一下,执行过程会有提醒。自己学会分析,抓重点再百度。
不管如何,自己今天终于达到预期目标:))