clang: error: cannot specify -o when generating multiple output files

14 views (last 30 days)
After dealing with issues on compiling c code with Matlba2013a in Maverick when using header include files I realized that i needed to to the following mex -v filename.c library.h
but now I get the following error:
clang: error: cannot specify -o when generating multiple output files
Any help would be greatly appreciated.
Thanks
here is the complete verbose:
-----------------------------
**************************************************************************
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/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
**************************************************************************
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
FILE = /Users/hsanabr/.matlab/R2013a/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2013a.app
-> CC = xcrun -sdk macosx10.8 clang
-> CC flags:
CFLAGS = -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -Dchar16_t=UINT16_T -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = /Applications/MATLAB_R2013a.app/bin/maci64/libmx.dylib /Applications/MATLAB_R2013a.app/bin/maci64/libmex.dylib /Applications/MATLAB_R2013a.app/bin/maci64/libmat.dylib -lc++
arguments = -DMX_COMPAT_32
-> CXX = xcrun -sdk macosx10.8 clang++
-> CXX flags:
CXXFLAGS = -fno-common -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -std=gnu++11 -stdlib=libc++
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = /Applications/MATLAB_R2013a.app/bin/maci64/libmx.dylib /Applications/MATLAB_R2013a.app/bin/maci64/libmex.dylib /Applications/MATLAB_R2013a.app/bin/maci64/libmat.dylib -lc++
arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
FFLAGS = -fexceptions -m64 -fbackslash
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = /Applications/MATLAB_R2013a.app/bin/maci64/libmx.dylib /Applications/MATLAB_R2013a.app/bin/maci64/libmex.dylib /Applications/MATLAB_R2013a.app/bin/maci64/libmat.dylib -L -lgfortran -L -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = xcrun -sdk macosx10.8 clang
-> Link flags:
LDFLAGS = -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013a.app/extern/lib/maci64/mexFunction.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmaci64
arguments = fsconv.h
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments = fsconv.h
----------------------------------------------------------------
-> xcrun -sdk macosx10.8 clang -c -I/Applications/MATLAB_R2013a.app/extern/include -I/Applications/MATLAB_R2013a.app/simulink/include -DMATLAB_MEX_FILE -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -Dchar16_t=UINT16_T -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "wr_gfit.c"
-> xcrun -sdk macosx10.8 clang -O -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013a.app/extern/lib/maci64/mexFunction.map -o "wr_gfit.mexmaci64" wr_gfit.o fsconv.h /Applications/MATLAB_R2013a.app/bin/maci64/libmx.dylib /Applications/MATLAB_R2013a.app/bin/maci64/libmex.dylib /Applications/MATLAB_R2013a.app/bin/maci64/libmat.dylib -lc++
clang: error: cannot specify -o when generating multiple output files
mex: link of ' "wr_gfit.mexmaci64"' failed.

Answers (1)

Dekun Pei
Dekun Pei on 16 Jun 2014
The way mex is used here ("mex -v filename.c library.h") makes "mex" treat the header file "fsconv.h" as an input file and it is being compiled separately.
If the "library.h" is being included in your "filename.c" file, you don't need to provide it to "mex" separately. If the header file is in your current directory, "mex" will find it automatically. If it is not and you get an error regarding not being able to located the header file. Using the "-I" flag to include the location to directory containing the header file as in the following example:
mex filename.c -I/usr/include
Note that there is no space between "-I" and "/usr/include".

Categories

Find more on MATLAB Compiler SDK in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!