Help with gfortran and mex with 2014b on Windows 7 64bit

조회 수: 2 (최근 30일)
Jon Paul Janet
Jon Paul Janet 2015년 5월 17일
댓글: dpb 2015년 5월 18일
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
Jon Paul Janet
Jon Paul Janet 2015년 5월 18일
편집: Jon Paul Janet 2015년 5월 18일
Glory be! It complies on my command line. I was using a bad copy of fintrf.h (I grabbed it online and it was out of date). So now that works. But the example still gives me unclassifiable statements if I try and mex it? i.e., timestwo.F:13.6:
mwPointer plhs(*), prhs(*)
1
Error: Unclassifiable statement at (1)
timestwo.F:16.6:
Now, Matlab is presumably linking to the updated version of the header in the extern folder, which is the one I was able to compile with. Somehow the mex is not activating the preprocessor?
dpb
dpb 2015년 5월 18일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by