Compiling mex with gfortran

조회 수: 5 (최근 30일)
Lukas Bystricky
Lukas Bystricky 2020년 3월 27일
I'm trying to compile some Fortran files into a mex file. I'm using an existing makefile, and I'm having issues linking the correct libraries with gfortran. The original makefile used the Intel compiler, with the libraries
MEXLIB = -lifcore -lirc -lsvml -limf -lgfortran -liomp5
I was able to find those libraries (replacing l with lib) in the matlab sys/os/glnxa64 directory, so I set the MEXLIBDIR to that. When I run make I get the following error:
/usr/bin/ld: cannot find -libifcore
/usr/bin/ld: cannot find -libirc
/usr/bin/ld: cannot find -libsvml
/usr/bin/ld: cannot find -libimf
/usr/bin/ld: cannot find -libgfortran
/usr/bin/ld: cannot find -libiomp5
collect2: error: ld returned 1 exit status
makefile:25: recipe for target 'mex' failed
How can I get gfortran to locate these libraries (if these are the correct ones)?
I'm running Matlab r2018a on Ubuntu 16.04 LTS.
Here's the (slightly simplified) makefile after I've edited it:
MEX=/opt/matlab/r2018a/bin/mex
FORTRAN = gfortran
FFLAGS = -c -fpic -openmp -O3
MEXLIBDIR = /opt/matlab/r2018a/sys/os/glnxa64
MEXLIB = -libifcore -libirc -libsvml -libimf -libgfortran -libiomp5
OBJS=\
file_a.o\
all: file_a mex
mex: file_b.F $(OBJS)
$(MEX) -v -compatibleArrayDims -O file_b.F $(OBJS) -L$(MEXLIBDIR) $(MEXLIB)
file_a: file_a.f
$(FORTRAN) $(FFLAGS) file_a.f

답변 (0개)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by