compiling for maci46
I'm using matlab 2008a on an 64-bit intel mac, but there are no mex files that end in ".maci64". How do I compile them myself?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Matlab BGL Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Jeff Gauthier
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
1) Download boost 1.36.0
2) Make a new compile-
#!/bin/bash -e
BOOST_DIR=
YASMIC_DIR=.
source ccfiles.sh
OFILES=`echo ${CCFILES} | sed -e 's/\.cc/\.o/g'`
CFLAGS="-O2 -DMATLAB_
#CFLAGS="-g -W -DMATLAB_
function echocmd {
echo $@
$@
}
for file in ${CCFILES}; do
echocmd g++ $CFLAGS $file
done
echocmd ar rc libmbgl-
echocmd rm ${OFILES}
3) Add the following line to the big case statement in private/compile.m
case 'MACI64'
libname = 'mbgl-macosx-
4) In theory, you should be able to run from the terminal:
[matlab_bgl] $ cd libmbgl
[matlab_
and everything will compille
Then in matlab:
>> cd matlab_bgl % or wherever it is
>> cd private
>> compile
And evrything should work.
Revision history for this message
|
#2 |
Thank you for the detailed instructions. Everything went well until the very last step.
I downloaded boost 1.36.0 from http://
-% sh compile-
g++ -O2 -DMATLAB_
g++ -O2 -DMATLAB_
g++ -O2 -DMATLAB_
g++ -O2 -DMATLAB_
g++ -O2 -DMATLAB_
g++ -O2 -DMATLAB_
g++ -O2 -DMATLAB_
g++ -O2 -DMATLAB_
g++ -O2 -DMATLAB_
ar rc libmbgl-
rm components.o max_flow.o orderings.o searches.o shortest_path.o spanning_trees.o statistics.o layouts.o planar.o
But compiling in matlab failed with this error:
>> cd matlab_bgl/private
>> compile
mex -O CFLAGS="\$CFLAGS -Wall" -I../libmbgl/
ld warning: in ../libmbgl/
Undefined symbols:
"_astar_
_mexFunction in astar_search_mex.o
"_astar_search", referenced from:
_mexFunction in astar_search_mex.o
"_astar_
_mexFunction in astar_search_mex.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
mex: link of ' "astar_
??? Error using ==> mex at 207
Unable to complete successfully.
Error in ==> compile at 105
eval(mexstr);
I don't know how to interpret this. Any thoughts on what to try next?
Revision history for this message
|
#3 |
In the
compile-
Modify the flags to include
-arch x86_64
So you should have
CFLAGS="-O2 -arch x86_64 -DMATLAB_
Then let me know what happens, after starting over.
It looks like g++ on the mac doesn't compile for the 64-bit platform by default.
David
Revision history for this message
|
#4 |
Success! But I had to make one more change, documented here for future reference.
The case for MACI64 should also have the large_arrays flag, like this:
case 'MACI64'
libname = 'mbgl-macosx-
With that, I got a small bit of example code to work:
>> clustering_
ans =
1
1
1
1
1
As I begin to use the code, I'll update this thread if anything goes wrong that seems specific to 64-bit intel macs.
Thank you for your help!
--Jeff
Revision history for this message
|
#5 |
Hello,
I'm using matlab R2017a on an 64-bit intel mac. I run the same sh script as reported above in the terminal, but I keep getting these two errors:
1)/Users/
call to 'next' is ambiguous
2) rm: planar.o: No such file or directory
Is there a way to fix this? Thank you for your help.
Best
Sal
Revision history for this message
|
#6 |
Sal,
I'm not sure if you're still working on this, but I managed to work around the issue you're having. The fix was to replace every call to 'next' within the boost directory with 'boost::next'
Somehow there's an ambiguity because there's a standard c++ next() function and one defined within boost, and the code can't decide which it should use, so you need to tell it which to use.
I performed the replacement by running " rpl -R 'next(' 'boost::next(' * " from inside the boost/graph/ directory.
After doing so, I actually ran into another issue, which was that, in boost/graph/
Once I corrected these two errors, everything compiled accordingly.
Cheers,
Keith
Revision history for this message
|
#7 |
Hi Keith,
I could not compile the library, although I added the boost-namespace in the graph directory. Could you send me your matlab-bgl directory as a zipped file?
Many thanks
Klemens
Revision history for this message
|
#8 |
Just because this really helped me today, I wanted to summarize what worked on macOS Mojave (10.14.6) with Matlab_R2017b. I'll summarize the steps from above with the changes incorporated.
1) Download boost 1.36.0
2) Make a new compile-
#!/bin/bash -e
BOOST_DIR=
YASMIC_DIR=.
source ccfiles.sh
OFILES=`echo ${CCFILES} | sed -e 's/\.cc/\.o/g'`
CFLAGS="-O2 -arch x86_64 -DMATLAB_
#CFLAGS="-g -W -DMATLAB_
function echocmd {
echo $@
$@
}
for file in ${CCFILES}; do
echocmd g++ $CFLAGS $file
done
echocmd ar rc libmbgl-
echocmd rm ${OFILES}
3) Add the following line to the big case statement in private/compile.m
case 'MACI64'
libname = 'mbgl-macosx-
4) Find and replace 'next(' with 'boost::next(' in boost_1_
I used Sublime Text 3 find and replace in directory (cmd+shift+f) with the expression: (?<!\w)next\(
This ensures you don't accidentally split a string that shouldn't be changed and cause a new problem (as I think happened with Keith above)
5) In theory, you should be able to run from the terminal:
[matlab_bgl] $ cd libmbgl
[matlab_
and everything will compille
5.5) For some reason, my compile still failed and I had to then go and manually edit the following file/line: ./yasmic/
Change "after = next(a_itr);" to "after = boost::
then: `sh compile-
6) Then in matlab:
>> cd matlab_bgl % or wherever it is
>> cd private
>> compile
And everything should work.