Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Exporting Fortran data to mat file

Kami_M_
초급자
3,730 조회수

Hi,

I am trying to create mat file from Fortran data using Matdata.

It needs libmat.lib, libmx.lib from Matlab library and libmat.dll and libmx.dll from Matlab bin directories. On the command line mode, where I set PATH and LIB of these files*, everything is OK. But when I am trying to run it from VS shell in the form of VF project, I get fatal errorLNK1107: invalid or corrupt file for dll file: cannot read at 0x2C8. The properties of the project have been configured by adding library directory and files (Attached Figs. 1,2)

Thank you

* set LIB=%LIB%;C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft and set PATH=%PATH%;C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft

0 포인트
1 솔루션
IanH
명예로운 기여자 III
3,731 조회수

You are specifying the path to the 64 bit libraries ("C:\...MATLAB\R2014b\extern\lib\win64\...") for a 32 bit build (the platform in VS is Win32).

Are you trying to build for 32 bit or 64 bit?

원본 게시물의 솔루션 보기

0 포인트
9 응답
IanH
명예로운 기여자 III
3,731 조회수

Remove the .DLL files from the additional dependencies property.

On Windows you link against an import library for a DLL (.lib extension), not directly against the DLL.

0 포인트
Kami_M_
초급자
3,731 조회수

Thank you Ian for the response.

I removed .dll files from additional dependencies and got a set of errors (Fig. 3 in attachment). Just to make it more clear, my main program is Seis2SHalf and Matdata which is mentioned in errors is a module that uses Matlab libraries.

0 포인트
IanH
명예로운 기여자 III
3,731 조회수

Those symbols are in libmat.lib and libmx.lib.  Did you leave the .lib files in the additional dependencies line?

0 포인트
Kami_M_
초급자
3,731 조회수

I also removed libmat.lib and libmx.lib from the additional dependencies in Linker/Input and I got the same errors (Fig. 3). Now, the only change in project properties is Matlab library path in Linker/General/"Additional library directories".

0 포인트
IanH
명예로운 기여자 III
3,731 조회수

Don't remove them - the .lib files need to be listed in the additional dependencies for the project that links MatData.obj.

If you are still having issues provide additional information about your project, for example by attaching the .vfproj.

0 포인트
mecej4
명예로운 기여자 III
3,731 조회수

Kami M: You have not absorbed a rather basic concept. You have to specify both which non-default libraries are to be linked with, and where those libraries are located. What you said #5, in effect, is "look for the additional libraries here <...>, but right now I don't need any". Simply add the import library names (not the DLL names) the "additional dependencies" list.

A similar situation exists w.rt. (i) include files and module files at compile time, and (ii) DLLs at run time. Include and module file requirements are embedded in the source code thorugh INCLUDE and USE statements. The information about DLL dependencies in the EXE you build is placed into the EXE by the linker, and the system loads those DLLs as needed by looking at the PATH environmental variable.

0 포인트
Kami_M_
초급자
3,731 조회수

mecej4: Thank you for your comment.

Actually, I did #5 just to show Ian that by removing/leaving lib files I get the same error message (Fig. 3). I added lib files and got the same error message. I think there is a mistake somewhere else. Attached is a simple example of my project (exporting 1,2 and 4D arrays to mat file).

0 포인트
IanH
명예로운 기여자 III
3,732 조회수

You are specifying the path to the 64 bit libraries ("C:\...MATLAB\R2014b\extern\lib\win64\...") for a 32 bit build (the platform in VS is Win32).

Are you trying to build for 32 bit or 64 bit?

0 포인트
Kami_M_
초급자
3,731 조회수

Thank you Ian, It works!

0 포인트
응답