声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 10261|回复: 10

[混合编程] 求助:将C文件转换成MEX文件时出错

[复制链接]
发表于 2006-10-25 22:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
在执行MEX filename.c时,系统提示:

  Could not find the compiler "cl" on the DOS path.
  Use mex -setup to configure your environment properly.

   C:\PROGRAM FILES\MATLAB704\BIN\WIN32\MEX.PL: Error: Unable to locate compiler.

请问这是什么原因啊?“cl“是什么compiler啊?在这之前我已经mex -setup过了,选的是Microsoft Visual c/c++ 6.0编译器。是因为这个编译器不在MATLAB下吗?当我用Lcc编译器的时候就没问题。请高手指点,谢谢!
回复
分享到:

使用道具 举报

发表于 2006-10-25 22:50 | 显示全部楼层
原帖由 arlay 于 2006-10-25 22:13 发表
在执行MEX filename.c时,系统提示:

  Could not find the compiler "cl" on the DOS path.
  Use mex -setup to configure your environment properly.

   C:\PROGRAM FILES\MATLAB704\BIN ...



先用mbuild -setup,再用mex -setup,如果没有错误的话,应该可以编译
发表于 2006-10-26 10:26 | 显示全部楼层
 楼主| 发表于 2006-11-2 11:35 | 显示全部楼层
1、mbuild -setup,选了msvc6.0编译器;
2、mcc -m filenames, 出错:
     Could not find the compiler "cl" on the DOS path.
  Use mbuild -setup to configure your environment properly.


  C:\PROGRAM FILES\MATLAB704\BIN\WIN32\\..\WIN32\MEX.PL: Error: Unable to locate compiler.

3、把msvc60engmatopts.bat中的
      rem************************
      rem General parameters
      rem************************
      set MATLAB=%MATLAB%
      set MSVCDir=%MSVCDir%
      set MSDevDir=%MSVCDir%\..\Common\msdev98
      set PATH=%MAVCDir%\BIN;%MSDevDir%\bin;%PATH%

      改为:

      rem************************
      rem General parameters
      rem************************
      set MATLAB=%MATLAB%
      set MSVCDir=C:Program files\Micro...\VC98
      set MSDevDir=%MSVCDir%\..\Common\msdev98
      set PATH=%MAVCDir%\BIN;%MSDevDir%\bin;%PATH%

      再mcc还是出错,出错提示跟上面一样,是什么原因阿?
 楼主| 发表于 2006-11-6 21:39 | 显示全部楼层
请高手指点啊,谢谢啦!^_^
发表于 2006-11-7 01:57 | 显示全部楼层
http://www.mathworks.com/support ... p;solution=1-1I5TNS

Subject:
Why do I get an error message regarding the "cl" compiler on the DOS path when compiling and linking engine programs in MATLAB 7.0.4 (R14SP2)?

Problem Description:
When I compile and link MATLAB Engine programs, MATLAB cannot find the compiler.
For example, type the following at the MATLAB command prompt:

optsFile = fullfile(matlabroot,'bin','win32','mexopts','msvc71engmatopts.bat');
compFile = fullfile(matlabroot,'extern','examples','eng_mat','engwindemo.c');
mex(compFile,'-f',optsFile)

The following error message occurs:
Could not find the compiler "cl" on the DOS path.
Use mex -setup to configure your environment properly.

D:\APPLICATIONS\MATLAB704\BIN\WIN32\MEX.PL: Error: Unable to locate compiler.

??? Error using ==> mex
Unable to complete successfully


Solution:
To solve the issue, set MSVCDir to the ACTUAL location of your MSVC install, for
example:
Make a copy of the "msvc71engmatopts.bat" file in the current working directory. Open and edit the file. In line 13, change the "MSVCDir" variable from:


set MSVCDir=%MSVCDir%
to:

set MSVCDir=C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7
(where C:\Program Files is the directory that contains Microsoft Visual Studio .NET 2003)

评分

1

查看全部评分

 楼主| 发表于 2006-11-9 15:56 | 显示全部楼层
thanks a lot! ^_^
 楼主| 发表于 2006-11-27 10:33 | 显示全部楼层
我选用的是msvc60编译器,把msvc60engmatopts.bat文件拷到当前工作目录下,然后将其中的13行
set MSVCDir=%MSVCDir%
改为
set MSVCDir=C:\Program Files\MATLAB704\extern\lib\win32\microsoft\msvc60
出错:
Could not find the compiler "cl" on the DOS path.
  Use mbuild -setup to configure your environment properly.


  C:\PROGRAM FILES\MATLAB704\BIN\WIN32\\..\WIN32\MEX.PL: Error: Unable to locate compiler

又改为:
set MSVCDir=C:\Program Files\MathWorks\MATLAB Component Runtime\v72\extern\lib\win32\microsoft\msvc60

但是依然出现同样的错误。

请问各位高手,这到底是什么原因阿?是我的MSVCDir找得不对吗?我是直接搜索的msvc60,搜到两个文件夹分别位于上面两个路径下,然后直接把路径拷贝过去的。

谢谢啦!
发表于 2006-11-27 10:51 | 显示全部楼层
原帖由 arlay 于 2006-11-27 10:33 发表
我选用的是msvc60编译器,把msvc60engmatopts.bat文件拷到当前工作目录下,然后将其中的13行
set MSVCDir=%MSVCDir%
改为
set MSVCDir=C:\Program Files\MATLAB704\extern\lib\win32\microsoft\msvc60
出错: ...



MSVCDir显然不对,msvc60你装哪儿上哪儿找去
发表于 2010-12-13 17:41 | 显示全部楼层
Please choose your compiler for building standalone MATLAB applications:

Would you like mbuild to locate installed compilers [y]/n? n

Select a compiler:
[1] Borland C++Builder version 6.0
[2] Borland C++Builder version 5.0
[3] Borland C/C++ (free command line tools) version 5.5
[4] Lcc C version 2.4.1
[5] Microsoft Visual C/C++ version 7.1
[6] Microsoft Visual C/C++ version 6.0

[0] None

Compiler: 5

The default location for Microsoft Visual C/C++ compilers is C:\Program Files\Microsoft Visual Studio .NET 2003,
but that directory does not exist on this machine.  

Use C:\Program Files\Microsoft Visual Studio .NET 2003 anyway [y]/n? y

Please verify your choices:

Compiler: Microsoft Visual C/C++ 7.1
Location: C:\Program Files\Microsoft Visual Studio .NET 2003

Are these correct?([y]/n): y
Warning: Mbuild requires that the Microsoft Visual C++ 7.0
directories "Vc7" and "Common7" be located within the same parent directory.
(Expected to find a directory named "Common7" in the directory 'C:\Program Files\Microsoft Visual Studio .NET 2003'.)
Try to update options file: C:\Users\岳青宇\Application Data\MathWorks\MATLAB\R14SP3\compopts.bat
From template:              E:\PROGRAM FILES\MATLAB71\BIN\win32\mbuildopts\msvc71compp.bat

Done . . .


--> ""E:\Program Files\MATLAB71\bin\win32\mwregsvr" "E:\Program Files\MATLAB71\bin\win32\mwcomutil.dll""

Error: DllRegisterServer in E:\Program Files\MATLAB71\bin\win32\mwcomutil.dll failed
Undefined subroutine &mexsetup::expire called at E:\Program Files\MATLAB71/bin/mexsetup.pm line 752.
??? Error using ==> mbuild
Unable to complete successfully
这个是怎么回事啊?mex  .c文件始终是失败的。

mex imsmooth.c
  Could not find the compiler "cl" on the DOS path.
  Use mex -setup to configure your environment properly.


  E:\PROGRAM FILES\MATLAB71\BIN\MEX.PL: Error: Unable to locate compiler.

??? Error using ==> mex
Unable to complete successfully


发表于 2010-12-13 17:41 | 显示全部楼层
求助,,,高手帮助啊……
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-29 17:27 , Processed in 0.067447 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表