- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am trying to call matlab functions within a fortran code.
for opening and closing .mat files. However I do not know how to
make the fortran compiler use the matlab libraries such as
libmx.lib libmat.lib libeng.lib so the fortran code
will compile and use "engOpen", "engPutVariable"etc
can anyone explain how to do this baring in mind that I am
new to fortran
Cheers
CHRIS
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are a couple of ways to do it. I assume you are using the visual development environment?
The simplest way, and one I recommend, is to right click on the Source Files folder in the Solution Explorer pane, select Add..Files..Existing files. Browse to the folder containing the libraries and select them to add them to the project. You may need to change the "Files of type" setting to show all files.
Another way is to add the library names to the Linker property page for additional dependencies including the full path.
If you are using the command line, just give the path to the libraries on the ifort command line along with other files or objects.
The simplest way, and one I recommend, is to right click on the Source Files folder in the Solution Explorer pane, select Add..Files..Existing files. Browse to the folder containing the libraries and select them to add them to the project. You may need to change the "Files of type" setting to show all files.
Another way is to add the library names to the Linker property page for additional dependencies including the full path.
If you are using the command line, just give the path to the libraries on the ifort command line along with other files or objects.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks steve
I tried those methods but still get the same error LNK2019:unresolved external
symbol _ENGOPEN. I am wondering if the _ in the fortran output error
will be causing a problem as it isn't in the matlab library like that, its just
ENGOPEN
Thanks CHRIS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The underscore is added by the compiler, so while the documentation may say ENGOPEN, the routine in the library would be called _ENGOPEN.
Are you perhaps using a MATLAB library that was built for use with Compaq Visual Fortran? If so, you will need to change the calling conventions to match CVF. The simplest way to do this is to go to the Fortran project properties, External Procedures, and change argument passing convention to CVF and string length argument passing to "after individual string arg". Then rebuild your application.
Are you perhaps using a MATLAB library that was built for use with Compaq Visual Fortran? If so, you will need to change the calling conventions to match CVF. The simplest way to do this is to go to the Fortran project properties, External Procedures, and change argument passing convention to CVF and string length argument passing to "after individual string arg". Then rebuild your application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve
That worked thanks very much for the help
CHRIS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a similar problem. I am using intel fortran in linux. I am trying to connect with matlab engine from fortran. Would you please let me know the solution for intel fortran? I was able to connect to matlab with g95 compiler. I need to run it using ifort.
A part of the errors I get are as follows:
/tmp/ifortMjMc0U.o: In function `MAIN__':
fengdemo.f:(.text+0x49): undefined reference to `engopen_'
fengdemo.f:(.text+0x76): undefined reference to `mxcreatedoublematrix_'
fengdemo.f:(.text+0x8d): undefined reference to `mxgetpr_'
fengdemo.f:(.text+0xae): undefined reference to `mxcopyreal8toptr_'
fengdemo.f:(.text+0xca): undefined reference to `engputvariable_'
fengdemo.f:(.text+0xec): undefined reference to `engevalstring_'
fengdemo.f:(.text+0x10b): undefined reference to `engevalstring_'
--------------------
Thank you.
I have a similar problem. I am using intel fortran in linux. I am trying to connect with matlab engine from fortran. Would you please let me know the solution for intel fortran? I was able to connect to matlab with g95 compiler. I need to run it using ifort.
A part of the errors I get are as follows:
/tmp/ifortMjMc0U.o: In function `MAIN__':
fengdemo.f:(.text+0x49): undefined reference to `engopen_'
fengdemo.f:(.text+0x76): undefined reference to `mxcreatedoublematrix_'
fengdemo.f:(.text+0x8d): undefined reference to `mxgetpr_'
fengdemo.f:(.text+0xae): undefined reference to `mxcopyreal8toptr_'
fengdemo.f:(.text+0xca): undefined reference to `engputvariable_'
fengdemo.f:(.text+0xec): undefined reference to `engevalstring_'
fengdemo.f:(.text+0x10b): undefined reference to `engevalstring_'
--------------------
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Whether it is possible and how to link IFort and Matlab can depend on which versions of Intel Fortran and Matlab you are working with. You did not provide any information on the versions.
Rejuvenating a five-year-old thread instead of starting anew is not a good idea, unless the compiler and Matlab versions you want to use now match the versions which the originator of the thread used.
Rejuvenating a five-year-old thread instead of starting anew is not a good idea, unless the compiler and Matlab versions you want to use now match the versions which the originator of the thread used.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page