声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2177|回复: 8

[混合编程] matlab调用fortran,mex出现问题?

[复制链接]
发表于 2014-6-29 21:03 | 显示全部楼层 |阅读模式

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

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

x
我的matlab7.1和fortran6.5,fortran编译器是6.0的。
在matlab工作区输入:mex -setup然后mex readraw.f90(我的fortran文件,包括接口程序和计算程序)出现:
>> 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] Digital Visual Fortran version 6.0 in C:\Program Files\Microsoft Visual Studio
[2] Lcc C version 2.4.1 in D:\PROGRAM FILES\MATLAB71\sys\lcc
[3] Microsoft Visual C/C++ version 6.0 in C:\Program Files\Microsoft Visual Studio

[0] None

Compiler: 1

Please verify your choices:

Compiler: Digital Visual Fortran 6.0
Location: C:\Program Files\Microsoft Visual Studio

Are these correct?([y]/n): y

Try to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R14SP3\mexopts.bat
From template:              D:\PROGRAM FILES\MATLAB71\BIN\win32\mexopts\df60opts.bat

Done . . .

Warning! The MathWorks has determined that Digital Fortran 6.0 has several
serious bugs, and highly recommends that you upgrade to the latest version
of Compaq Fortran.

***************************************************************************
  Warning: The file extension of 32-bit Windows MEX-files was changed
           from ".dll" to ".mexw32" in MATLAB 7.1 (R14SP3). The generated  
           MEX-file will not be found by MATLAB versions prior to 7.1.
           Use the -output option with the ".dll" file extension to
           generate a MEX-file that can be called in previous versions.
           For more information see:  
           MATLAB 7.1 Release Notes, New File Extension for MEX-Files on Windows
***************************************************************************

>> mex redaraw.f90

  D:\PROGRAM FILES\MATLAB71\BIN\MEX.PL: Error: 'redaraw.f90' not found.

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

请问大侠们这是什么原因?
回复
分享到:

使用道具 举报

发表于 2014-6-29 21:35 | 显示全部楼层
把要编译文件所在文件夹设置到当前路径下试试
 楼主| 发表于 2014-6-29 22:10 | 显示全部楼层
本帖最后由 wgun 于 2014-6-29 22:15 编辑
chybeyond 发表于 2014-6-29 21:35
把要编译文件所在文件夹设置到当前路径下试试

我把matlab工作区的路径设置到编译文件所在的路径了,这样对吗?还是不行,出现上面的错误
发表于 2014-6-29 23:27 | 显示全部楼层
wgun 发表于 2014-6-29 22:10
我把matlab工作区的路径设置到编译文件所在的路径了,这样对吗?还是不行,出现上面的错误

把currentfolder设置为编译文件所在文件夹的最后一级目录
 楼主| 发表于 2014-6-30 01:11 | 显示全部楼层
chybeyond 发表于 2014-6-29 23:27
把currentfolder设置为编译文件所在文件夹的最后一级目录

是current directory吗?
发表于 2014-6-30 08:35 | 显示全部楼层
wgun 发表于 2014-6-30 01:11
是current directory吗?

current folder 11111.jpg
 楼主| 发表于 2014-6-30 12:11 | 显示全部楼层

那就是一个地方,我的7.1版本的,显示是current directory,和你的current folder是一样的。我原来就是设置为编译文件所在文件夹的最后一级目录,但是还是出现上面的那个错误。我在网上搜了,好多出现和我一样的问题,就是没答案。是我的fortran编译器版本太老吗?
发表于 2014-6-30 15:02 | 显示全部楼层
wgun 发表于 2014-6-30 12:11
那就是一个地方,我的7.1版本的,显示是current directory,和你的current folder是一样的。我原来就是设 ...

没遇到过这样的问题,可能是版本兼容,matlab各版本支持的编译器:http://www.mathworks.cn/support/sysreq/previous_releases.html


       
 楼主| 发表于 2014-6-30 20:52 | 显示全部楼层
本帖最后由 wgun 于 2014-6-30 21:23 编辑
chybeyond 发表于 2014-6-30 15:02
没遇到过这样的问题,可能是版本兼容,matlab各版本支持的编译器:http://www.mathworks.cn/support/sysr ...

谢谢,chybeyond,换成matlab7.0就行了,但是编译失败,可能是我的fortran程序有错吧。
你能给我一个能编译的fortran程序例子吗,最简单的例子就行,我的邮箱38432603@qq.com,先谢了啊。请看图片附件,matlab7.0支持fortran6.1和6.6吗?后面都打×了



m7.jpg
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-4-28 02:37 , Processed in 0.169823 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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