How do I create a MEX file

Solution Number: 31087

Date Last Modified: 2003-12-10
  
Product:    MATLAB 6.1 ==> Current Version
Platform:    Information Not Available

 

Problem Description
How do I create a MEX file using the Microsoft Developer Studio and Compaq Visual Fortran 6.5?

The documentation in the External Interfaces Guide outlines the procedure to do the above in the Visual C++ environment. This document outlines this procedure for Fortran programs in the MSDev IDE.


Solution:
Compiling MEX-Files with the MSDEV IDE for Compaq Visual Fortran 6.5:

To build MEX-files with the MSDEV IDE for Compaq Visual Fortran 6.5:

1. Inside the IDE, go to FILE-->NEW. Select "Fortran Dynamic Link Library". Provide a project name. In the event you do not see this option, please check the installation of Compaq Visual Fortran. There should be an .awx file that should be installed by Compaq Visual Fortran. If not check with Compaq for troubleshooting.

2. Create an empty DLL project.

3. Once the project is created, add the files yprimefg.F and yprimef.F from the $MATLAB/extern/examples/mex/ directory to your project. Here, $MATLAB refers to the root MATLAB directory on your computer.

4. Create a file with extension .DEF and add it to the project (anywhere should be fine; resources for example). The .DEF file should have the following text (if your project name is myproj, then a dll will be created called myproj.dll, used below):


LIBRARY myproj.dll
EXPORTS
_MEXFUNCTION@16


5. Select the menu Project-->Settings... Here, under Fortran, please change the following:
Fortran tab:
a. Category: Fortran Language
Source Form: Force fixed form
Fixed form length: 80 columns
b. Category: External Procedures
External Name Interpretation: Upper case
Argument Passing convention: Default
String Length Argument Passing: After All Args
Link tab:
a. Category Input:
Add these libraries to Object/library modules: libmx.lib libmex.lib libmat.lib ....
Additional library path: <MATLAB>/extern/lib/win32/microsoft/msvc60

6. The above should compile and run and can be run as a MEX file in MATLAB.

We expect that similar steps are performed for Compaq Visual Fortran 6.6. It is not practical, however, for us to offer complete technical support on the details of using any specific one of the large number of IDE environments our customers use. If you need detailed assistance with the particular settings needed to get your IDE environment to generate code that successfully compiles and runs with our products, we suggest you contact the manufacturer of your IDE to get information or expert technical assistance in using it.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值