mex & Blass library linking error

14 views (last 30 days)
Zain Nawaz
Zain Nawaz on 19 Feb 2020
Mex linking error undefined blass libraries dtrmm and dgemm
Error using mex function blass linking error
Error using mex
/tmp/mex_33768366225260_4769/fmmshift.o: In function `shift_m2m':
fmmshift.c:(.text+0x702): undefined reference to `dtrmm_'
/tmp/mex_33768366225260_4769/fmmshift.o: In function `shift_m2ps':
fmmshift.c:(.text+0xff1): undefined reference to `dgemm_'
/tmp/mex_33768366225260_4769/fmmshift.o: In function `shift_p2p':
fmmshift.c:(.text+0x1e38): undefined reference to `dtrmm_'
collect2: error: ld returned 1 exit status
Error in make (line 83)
mex(cflags,define{:},include,link, ...
I am tottally blank not able to get how to run it.
I am using matlab r2018b, linux OS is ubuntu 18.04.4 LTS.
function make(varargin)
%MAKE Makefile for FMM2D.
% MAKE(ARG1,...) compiles FMM2D with the compiler arguments ARG1,
% ... using the MEX-command. With no arguments, default
% platform-dependent define arguments are used (the -D switch).
% S. Engblom 2011-04-17 (mexmaci64, 7.11)
% S. Engblom 2011-04-17 (mexmaci64, 7.10)
% S. Engblom 2011-03-07 (mexa64, 7.11)
% S. Engblom 2010-02-02 (mexs64, 7.7)
% S. Engblom 2010-02-02 (mexa64, 7.8)
% S. Engblom 2010-01-13 (mexmaci)
% S. Engblom 2007-09-01 (mexs64)
% S. Engblom 2006-07-10 (mexa64)
% S. Engblom 2005-03-22 (mexmac)
% Public defines:
%
% -use '-DmwIndex=int' for platforms where mex is not automatically
% linked against the library defining the mwIndex type,
%
% -use '-DBLASINT=size_t' for the (bad!) platforms where the 'int' in
% the declaration of BLAS subroutines is in fact a 'size_t' and
% sizeof(size_t) > sizeof(int),
%
% -use '-DPRINTTIME' to print precise timings of the FMM-algorithm,
%
% For experimental use:
%
% '-DFMM_INLINECOMPLEX' (recommended) avoids complex arithmetic in various
% places in the FMM-algorithm and uses inline versions instead,
%
% '-DFMM_INLINECOMPLEX_DIRECT' (recommended) uses "Quick-and-dirty" versions
% of direct evaluations. On some platforms, it is faster by a factor of up
% to 8 not to rely on certain math-functions and/or complex arithmetics, but
% to write the complex arithmetic inline,
%
% '-DFMM_SHRINK' (recommended) sets Postsplit shrinking of boxes on/off,
%
% '-DFMM_THETA=<value>' (default 0.5) sets the constant of
% well-separatedness in the theta-criterion,
%
% '-DFMM_MESHRATIO=<value>' (default 2.0) tunes the criterion for
% splitting long edges in the mesh.
%
% Make some effort in finding good optimization flags!
mx = mexext;
ver = version;
% possible defines
define = {'-DmwIndex=int' ... % (1)
'-DBLASINT=size_t' ... % (2)
'-DPRINTTIME' ... % (3)
'-DFMM_INLINECOMPLEX' ... % (4)
'-DFMM_INLINECOMPLEX_DIRECT' ... % (5)
'-DFMM_SHRINK'}; % (6)
% (edit defaults below)
% path, include and link path, source
s = pwd;
include = ['-I' s '/source'];
link = ['-L' s '/source'];
source = {[s '/source/fmm2d.c'] ...
[s '/source/fmm.c'] ...
[s '/source/fmmshift.c'] ...
[s '/source/direct.c'] ...
[s '/source/expint.c']};
if strcmp(mx,'mexa64')
if ~strncmp(version,'7.8',3) && ~strncmp(version,'7.11',4)
warning(['Extension .' mexext ...
' tested with Matlab version(s) 7.8 and 7.11 only.']);
end
cflags = ['CFLAGS=-fPIC -fno-omit-frame-pointer -std=c99 -O3 ' ...
'-D_GNU_SOURCE -pthread -fexceptions'];
link = [link ' -lmwblas'];
if strncmp(version,'7.11',4)
link = [link ' -L' matlabroot '/sys/os/glnxa64'];
end
define = define([2 4:6]);
if nargin > 0, define = varargin; end
mex(cflags,define{:},include,link, ...
'-largeArrayDims','-outdir',s, ...
source{:});
elseif strcmp(mx,'mexmaci')
if ~strncmp(version,'7.8',3)
warning(['Extension .' mexext ...
' tested with Matlab version(s) 7.8 only.']);
end
cflags = 'CC=gcc -std=c99 -fast';
link = [link ' -lmwblas'];
define = define([4:6]);
if nargin > 0, define = varargin; end
mex(cflags,define{:},include,link, ...
'-outdir',s, ...
source{:});
elseif strcmp(mx,'mexmaci64')
if ~strncmp(version,'7.10',4) && ~strncmp(version,'7.11',4)
warning(['Extension .' mexext ...
' tested with Matlab version(s) 7.10 and 7.11 only.']);
end
cflags = 'CC=gcc -std=c99 -fast';
link = [link ' -lmwblas'];
define = define([2 4:6]);
if nargin > 0, define = varargin; end
mex(cflags,define{:},include,link, ...
'-largeArrayDims','-outdir',s, ...
source{:});
elseif strcmp(mx,'mexmac')
warning('Platform never tried.');
cflags = 'CC=gcc -std=c99';
define = define(4:6);
if nargin > 0, define = varargin; end
mex(cflags,define{:},include,link, ...
'-outdir',s, ...
source{:});
elseif strcmp(mx,'mexw32')
warning('Platform never tried.');
cflags = ['COMPFLAGS=-c -DMATLAB_MEX_FILE -fno-omit-frame-pointer -std=c99' ...
'-D_GNU_SOURCE -fexceptions'];
include(include == '/') = '\';
link(link == '/') = '\';
for i = 1:numel(source)
source{i}(source{i} == '/') = '\';
end
define = define(4:6);
if nargin > 0, define = varargin; end
mex(cflags,define{:},include,link, ...
'-outdir',s, ...
source{:},[matlabroot '\extern\lib\win32\microsoft\libmwblas.lib']);
elseif strcmp(mx,'mexglx')
warning('Platform never tried.');
cflags = ['CFLAGS=-fPIC -fno-omit-frame-pointer -std=c99 ' ...
'-D_GNU_SOURCE -pthread -fexceptions'];
link = [link ' -lmwblas'];
define = define(4:6);
if nargin > 0, define = varargin; end
mex(cflags,define{:},include,link, ...
'-outdir',s, ...
source{:});
elseif strcmp(mx,'mexs64')
if ~strncmp(version,'7.7',3)
warning(['Extension .' mexext ...
' tested with Matlab version(s) 7.7 only.']);
end
cflags = 'CFLAGS=-xc99 -xcode=pic32';
define = define(4:6);
if nargin > 0, define = varargin; end
mex(cflags,define{:},include,link,'-largeArrayDims', ...
'-outdir',s, ...
source{:});
else
warning('New platform. Trying default make.');
define = define(4:6);
if nargin > 0, define = varargin; end
mex(define{:},include,link, ...
'-outdir',s, ...
source{:});
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!