I have downloaded a script and it works on a windows pc but on my macbook air (OSX10.8, matlab 2012b, xcode 4.6 with patch) it just won't work. Running the script does this:
Invalid MEX-file '/Users/Till/Documents/Arbeit/Forschung/Matlab/EVM_Matlab/matlabPyrTools/corrDn.mexmaci64':
dlopen(/Users/Till/Documents/Arbeit/Forschung/Matlab/EVM_Matlab/matlabPyrTools/corrDn.mexmaci64, 1): no suitable image found. Did
find:
/Users/Till/Documents/Arbeit/Forschung/Matlab/EVM_Matlab/matlabPyrTools/corrDn.mexmaci64: file too short
*Compiling the .c file:*
>> mex -v corrDn.c
**************************************************************************
Warning: Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require
the use of -largeArrayDims and remove the -compatibleArrayDims
option. For more information, see:
http://www.mathworks.com/help/techdoc/matlab_external/bsflnue-1.html
**************************************************************************
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
FILE = /Users/Till/.matlab/R2012b/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2012b.app
-> CC = llvm-gcc-4.2
-> CC flags:
CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/ -mmacosx-version-min=10.5 -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2012b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = llvm-g++-4.2
-> CXX flags:
CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/ -mmacosx-version-min=10.5
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB_R2012b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
FFLAGS = -fexceptions -m64 -fbackslash
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -L/Applications/MATLAB_R2012b.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = llvm-gcc-4.2
-> Link flags:
LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/ -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2012b.app/extern/lib/maci64/mexFunction.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmaci64
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------
-> llvm-gcc-4.2 -c -I/Applications/MATLAB_R2012b.app/extern/include -I/Applications/MATLAB_R2012b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/ -mmacosx-version-min=10.5 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "corrDn.c"
-> llvm-gcc-4.2 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/ -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2012b.app/extern/lib/maci64/mexFunction.map -o "corrDn.mexmaci64" corrDn.o -L/Applications/MATLAB_R2012b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
Undefined symbols for architecture x86_64:
"_internal_reduce", referenced from:
_mexFunction in corrDn.o
"_internal_wrap_reduce", referenced from:
_mexFunction in corrDn.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
mex: link of ' "corrDn.mexmaci64"' failed.
Error using mex (line 206)
Unable to complete successfully.
  • I am definitely not an expert on this and I am lost! Any ideas for help?
Thanks in advance! ti*

 Akzeptierte Antwort

Jan
Jan am 26 Feb. 2013

1 Stimme

The file corrDn.c calls the functions "internal_reduce" and "internal_wrap_reduce", but the corresponding function definitions are not found. Either they are located in another C-file, and then both C-files must appear in the arguments of the mex command. Or you do not have the corresponding files and asking the author is the best idea.

Weitere Antworten (2)

TAB
TAB am 26 Feb. 2013
Bearbeitet: TAB am 26 Feb. 2013

0 Stimmen

mex files are compiled binary code which are platform dependent. A mex file compiled for windows platform will not work on other.

2 Kommentare

The trace above showed that building the mex failed:
Undefined symbols for architecture x86_64:
"_internal_reduce", referenced from:
_mexFunction in corrDn.o
"_internal_wrap_reduce", referenced from:
_mexFunction in corrDn.o
t
t am 26 Feb. 2013
I can compile the .c file but not link it. How do I do that? mex...?

Melden Sie sich an, um zu kommentieren.

t
t am 5 Mär. 2013

0 Stimmen

Thanks, I finally got it...!

2 Kommentare

Hugo Sanabria
Hugo Sanabria am 12 Jun. 2014
Would you mind sharing how you solve it? I have a similar problem.
To Hugo: I have the same problem as above. What Jan said is right. The command "internal_reduce" and "internal_wrap_reduce" are functions defined in other C-files. So we need to call them in the code. Here is my code:
mex -compatibleArrayDims corrDN.c convolve.c edges.c wrap.c
The command "internal_reduce" is defined in the file 'convolve.c', and the command "internal_wrap_reduce" is defined in the file 'wrap.c'. Another command in 'convolve.c' is defined in the 'edges.c'. That is why I added the three C-files in the code (they are all in the same directory). Then the problem should be fixed.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Hilfe-Center und File Exchange

Gefragt:

t
t
am 26 Feb. 2013

Kommentiert:

am 2 Apr. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by