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

Language:
English Edit question
Status:
Solved
For:
Matlab BGL Edit question
Assignee:
No assignee Edit question
Solved by:
Jeff Gauthier
Solved:
2009-05-08
Last query:
2009-05-08
Last reply:
2009-05-07
David Gleich (dgleich) said : #1

1) Download boost 1.36.0

2) Make a new compile-macosx-intel-64-large.sh file with these contents and *** Update the boost_dir to where you downloaded 1.36.0 ***

#!/bin/bash -e

BOOST_DIR=${HOME}/dev/lib/boost_1_36_0/
YASMIC_DIR=.

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

CFLAGS="-O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I${BOOST_DIR} -I${YASMIC_DIR}"
#CFLAGS="-g -W -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I${BOOST_DIR} -I${YASMIC_DIR}"

function echocmd {
 echo $@
 $@
}

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

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 compile-macosx-intel-64-large.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 http://www.boost.org/users/history/ . Running the sh script seemed to work as expected:

-% sh compile-macosx-intel-64-large.sh
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. components.cc
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. max_flow.cc
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. orderings.cc
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. searches.cc
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. shortest_path.cc
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. spanning_trees.cc
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. statistics.cc
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. layouts.cc
g++ -O2 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I/Developer/usr/lib/boost_1_36_0/ -I. planar.cc
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
     eval(mexstr);

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

David Gleich (dgleich) said : #3

In the

compile-macosx-intel-64-large.sh

Modify the flags to include

-arch x86_64

So you should have

CFLAGS="-O2 -arch x86_64 -DMATLAB_BGL_LARGE_ARRAYS -fPIC -c -I${BOOST_DIR} -I${YASMIC_DIR}"

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

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 =

     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

Salvatore Lattanzio (lat010) said : #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/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.

Best
Sal