Help with gfortran and mex with 2014b on Windows 7 64bit
3 views (last 30 days)
Show older comments
I am trying to link gfortran (Minigw-w64) with Matlab 2014b on 64bit Windows 7. I have downloaded and run gnumex. If I call "mex -setup" and I can see the gcc compiler in Matlab, with the correct path. I am trying to test my setup on a minimal hello world! program, "hello.f". I can call "gfortran hello.f" from the Windows command line and get the correct result. I have added gcc to my system path. However, when I call "mex -v hello.f" in Matlab, I get the following output:
Cannot export mexFunction: symbol not defined
C:\Users\JP\AppData\Local\Temp\mex_9AxT5n\hello.obj:hello.f:(.text+0x2f): undefined reference to `_gfortran_st_write'
C:\Users\JP\AppData\Local\Temp\mex_9AxT5n\hello.obj:hello.f:(.text+0x47): undefined reference to `_gfortran_transfer_character_write'
C:\Users\JP\AppData\Local\Temp\mex_9AxT5n\hello.obj:hello.f:(.text+0x4f): undefined reference to `_gfortran_st_write_done'
C:\Users\JP\AppData\Local\Temp\mex_9AxT5n\hello.obj:hello.f:(.text.startup+0x1c): undefined reference to `_gfortran_set_args'
C:\Users\JP\AppData\Local\Temp\mex_9AxT5n\hello.obj:hello.f:(.text.startup+0x30): undefined reference to `_gfortran_set_options'
collect2.exe: error: ld returned 1 exit status
link command: gcc -shared C:\Users\JP\AppData\Roaming\MATHWO~1\MATLAB\R2014b\gnumex\mex.def -o hello.mexw64 -LC:\Users\JP\AppData\Roaming\MATHWO~1\MATLAB\R2014b\gnumex -s C:\Users\JP\AppData\Local\Temp\mex_9AxT5n\hello.obj -llibmx -llibmex -llibmat
E:\MATLAB\R2014B\BIN\MEX.PL: Error: Link of 'hello.mexw64' failed.
Any advice is highly appreciated!
9 Comments
dpb
on 18 May 2015
There should be an up-to-date copy of fintrf.h in the distribution (altho I don't think it's changed in quite a number of releases) in the ..\external\include directory.
Need to ensure that's the right location specified in the INCLUDE environment variable; obviously one is being found or you'd have the error of 'file not found' when it reached the INCLUDE statement.
That does seem to leave the alternative the preprocessor wasn't called since the MWPOINTER declaration hasn't gotten substituted at all. Even if the -D weren't set for one of the 64-bit options since neither the #if nor the #else path was executed as MWPOINTER wasn't substituted at all seems to be so that it just didn't do anything at all.
For fpp here I had to use the
/m Do macro expansion outside of preprocessor lines
switch to make fintrf.h work correctly. As said, not sure what gfortran does about a preprocessor; whether it packages a specific version with the distribution or relies on whatever is on the system independent.
Answers (0)
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!