mex with g++4.8 with Boost issues

3 views (last 30 days)
gujax
gujax on 16 Sep 2016
Edited: Walter Roberson on 24 Sep 2016
I am trying to build a mex file on OS X with gnu++-4.8. But ending up with error msg. In the command line it links to libc++. I think libc++ is incompatible with gnu++-4.8. I thought this library will or should not get linked by this option nor should clang++ be used. I am confused by all the message below. Can some please help me wade through?
I have already posted two questions on similar topics but still struggling for a solution.
Thanks
mex -v CXX='/usr/local/bin/g++-4.8 ' CXXFLAGS='-std=gnu++11' gl_file.cpp /Users/slib/io/glFile.cpp -I/Users/boost_1_51_0 -I/Users/slib/include -I/Users/matutils -I/Users/eigen-eigen-5097c01bcdc4
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:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
No MEX options file identified; looking for an implicit selection.
... Looking for compiler 'Xcode Clang++' ...
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('7.3.1').
... Executing command '
agreed=7.3.1
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('7.3.1').
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk' ...No.
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk' ...No.
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk' ...Yes.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk' ...No.
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk' ...No.
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk' ...Yes.
... Executing command 'echo /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk | rev | cut -c1-10 | rev | egrep -oh '[0-9]+\.[0-9]+'' ...Yes ('10.11').
Found installed compiler 'Xcode Clang++'.
Options file details
-------------------------------------------------------------------
Compiler location: /Applications/Xcode.app/Contents/Developer
Options file: /Applications/MATLAB_R2016a.app/bin/maci64/mexopts/clang++_maci64.xml
Compiler location: /Applications/Xcode.app/Contents/Developer
Options file: /Applications/MATLAB_R2016a.app/bin/maci64/mexopts/clang++_maci64.xml
CMDLINE200 : /usr/local/bin/g++-4.8 -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.11 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -framework Cocoa -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016a.app/extern/lib/maci64/mexFunction.map" -stdlib=libc++ -O -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016a.app/extern/lib/maci64/mexFunction.map" /var/folders/_j/0zxcvyh55jnggzgr3x9zxfk9_43znl/T/mex_3401169421544_7178/gl_file.o /var/folders/_j/0zxcvyh55jnggzgr3x9zxfk9_43znl/T/mex_3401169421544_7178/glFile.o -L"/Applications/MATLAB_R2016a.app/bin/maci64" -lmx -lmex -lmat -o ngl_file.mexmaci64
CXX : /usr/local/bin/g++-4.8
DEFINES : -DMX_COMPAT_32 -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
CXXFLAGS : -std=gnu++11
INCLUDE : -I/Users/boost_1_51_0 -I/Users/slib/include -I/Users/matutils -I/Users/eigen-eigen-5097c01bcdc4 -I"/Applications/MATLAB_R2016a.app/extern/include" -I"/Applications/MATLAB_R2016a.app/simulink/include"

Accepted Answer

gujax
gujax on 24 Sep 2016
This is resolved. In Matlab R2016a mexopts.sh in ~/.matlab folder has no function. Do not create a copy of it. Instead one should edit the xml files in the .matlab/R2016 directory.
If xml files are not found they can be first generated using the mex -setup command.
mex -setup C++ |
will generate mex_C++_maci64.xml file.
If you want to use Clang then CXX and CXXFLAGS should be the default (which includes libc++ library).
If you have to use GNU gcc>4.2 then change CXX and CXXFLAGS in the xml file to that as in example above in the question asked. Also remove any mention of libc++ or remove instances of any 'not found xxx'.

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!