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_
Einsteiger
3.716Aufrufe

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 Kudos
1 Lösung
IanH
Geehrter Beitragender III
3.717Aufrufe

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?

Lösung in ursprünglichem Beitrag anzeigen

9 Antworten
IanH
Geehrter Beitragender III
3.717Aufrufe

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.

Kami_M_
Einsteiger
3.717Aufrufe

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.

IanH
Geehrter Beitragender III
3.717Aufrufe

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

Kami_M_
Einsteiger
3.717Aufrufe

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".

IanH
Geehrter Beitragender III
3.717Aufrufe

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.

mecej4
Geehrter Beitragender III
3.717Aufrufe

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.

Kami_M_
Einsteiger
3.717Aufrufe

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).

IanH
Geehrter Beitragender III
3.718Aufrufe

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?

Kami_M_
Einsteiger
3.717Aufrufe

Thank you Ian, It works!

Antworten