compiling for maci46

Asked by Jeff Gauthier on 2009-04-28

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

English Edit question
Matlab BGL Edit question
No assignee Edit question
Solved by:
Jeff Gauthier
Last query:
Last reply:
David Gleich (dgleich) said : #1

1) Download boost 1.36.0

2) Make a new file with these contents and *** Update the boost_dir to where you downloaded 1.36.0 ***

#!/bin/bash -e


OFILES=`echo ${CCFILES} | sed -e 's/\.cc/\.o/g'`


function echocmd {
 echo $@

for file in ${CCFILES}; do
 echocmd g++ $CFLAGS $file

echocmd ar rc libmbgl-macosx-intel-64-large.a ${OFILES}

echocmd rm ${OFILES}

3) Add the following line to the big case statement in private/compile.m

    case 'MACI64'
        libname = 'mbgl-macosx-intel-64-large';

4) In theory, you should be able to run from the terminal:

[matlab_bgl] $ cd libmbgl
[matlab_bgl/libmbgl] $ sh

and everything will compille

Then in matlab:

>> cd matlab_bgl % or wherever it is
>> cd private
>> compile

And evrything should work.

Jeff Gauthier (gauthier-salk) said : #2

Thank you for the detailed instructions. Everything went well until the very last step.

I downloaded boost 1.36.0 from . Running the sh script seemed to work as expected:

-% sh
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I.
ar rc libmbgl-macosx-intel-64-large.a components.o max_flow.o orderings.o searches.o shortest_path.o spanning_trees.o statistics.o layouts.o planar.o
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/include -L../libmbgl -lmbgl-macosx-intel-64-large astar_search_mex.c
ld warning: in ../libmbgl/libmbgl-macosx-intel-64-large.a, file is not of required architecture
Undefined symbols:
  "_astar_search_hfunc_visitor", referenced from:
      _mexFunction in astar_search_mex.o
  "_astar_search", referenced from:
      _mexFunction in astar_search_mex.o
  "_astar_search_hfunc", referenced from:
      _mexFunction in astar_search_mex.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

    mex: link of ' "astar_search_mex.mexmaci64"' failed.

??? Error using ==> mex at 207
Unable to complete successfully.

Error in ==> compile at 105

I don't know how to interpret this. Any thoughts on what to try next?

David Gleich (dgleich) said : #3

In the

Modify the flags to include

-arch x86_64

So you should have


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.


Jeff Gauthier (gauthier-salk) said : #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-intel-64-large';
        large_arrays = 1;

With that, I got a small bit of example code to work:

>> clustering_coefficients(sparse(ones(5)))

ans =


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!


Salvatore Lattanzio (lat010) said : #5


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/salvatorelattanzio/Documents/boost_1_36_0/boost/graph/make_maximal_planar.hpp:148:31: error:
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.


Keith (hesken) said : #6


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/push_relabel_max_flow.hpp there seems to be a bug. On line 430, topo_boost::next(n) is declared. The declaration should actually be topo_next(n), as topo_boost isn't a class, and topo_next is called later in the code, but was never defined.

Once I corrected these two errors, everything compiled accordingly.


Klemens Esterle (klemens12) said : #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