diff --git a/.gitignore b/.gitignore index a220a20..4addd9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ *.mexw64 *.mexa64 +*.mexmaci64 *.o *.asv *.pdp *.mexw64.pdb pathdef.m jldict.mat +*DS_Store \ No newline at end of file diff --git a/jl.m b/jl.m index c5c6b73..b4b951d 100644 --- a/jl.m +++ b/jl.m @@ -13,11 +13,24 @@ function varargout = mexn(nout, fn, varargin) jl.check_initialized; outputs = cell(nout+1, 1); - [outputs{:}] = mexjulia('jl_mex', fn, varargin{:}); - varargout = outputs(2:end); - result = outputs{1}; - if ~islogical(result) - throw(result); + try + [outputs{:}] = mexjulia('jl_mex', fn, varargin{:}); + varargout = outputs(2:end); + result = outputs{1}; + if ~islogical(result) + throw(result); + end + catch err + warning('Something went wrong') + warning(err.message) + warning('Stack trace follows:') + w = warning('query'); + for i = 1:length(err.stack) + if ~strcmp(w(1).state,'off') + disp(err.stack(i)) + end + end + varargout{1} = []; end end @@ -229,7 +242,7 @@ function config(exe) % set ldflags ldflags = ['-L"' jl.get('lib_dir') '"']; if ~ispc - ldflags = [ldflags ' -Wl,-rpath="' jl.get('lib_dir') '"']; + ldflags = [ldflags ' -Wl,-rpath "' jl.get('lib_dir') '"']; end jl.set('build_ldflags', ldflags); @@ -283,6 +296,7 @@ function build() else mex_ptrn = 'mex LDFLAGS=''%s $LDFLAGS'' -v -largeArrayDims -outdir "%s" %s %s %s'; end + src = ['"' src '"']; mex_cmd = sprintf(mex_ptrn, ldflags, jl.this_dir, cflags, src, ldlibs); fprintf('The mex command to be executed:\n%s\n', mex_cmd); eval(mex_cmd);