Posts Tagged ‘mac os x’

Compiling and running qslim on Mac OS x

Thursday, May 23rd, 2013

I recently successfully compiled and executed qslim on mac os x. It took a little tweaking but here’s how I did it.

fltk

Before anything else, be sure to install fltk. I did this using macports:


sudo port install fltk

libgfx

Then, following the instructions in qslim-2.1/README.txt, I first compiled libgfx:


cd libgfx
./configure

The libpng support seems out of date and I don’t really need it so in raster-png.cxx I replaced:


//#ifdef HAVE_LIBPNG
#if false

memcopy was shoing up undefined so I added the following include to raster.cxx:


#include <cstring>

Similarly there was a missing include in time.cxx:


#elif defined(HAVE_TIMES)
#include <sys/times.h>

Know, while inside libgfx I issue:


make -C src

mixkit

First travel inside mixkit and configure:


cd ../mixkit
./configure

Trying to make I got a bunch of errors of the form:


MxDynBlock.h:44:33: Error: 'resize' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
MxDynBlock.h:44:33: Error: note: declarations in dependent base 'MxBlock<MxStdModel*>' are not found by unqualified lookup
MxDynBlock.h:44:33: Error: note: use 'this->resize' instead

There’re at least two ways to fix this. You can add this-> everywhere gcc is tell you to: edit MxStack.h and MxDynBlock.h or you can add -fpermissive to the CXXFLAGS. This is awkwardly done not in mix-config but in ../libgfx/gfx-config. Where you can edit into something like:


CXXFLAGS = -g -O2  -I/Users/ajx/Downloads/qslim-2.1/libgfx/include -DHAVE_CONFIG_H $(WIN_FLAGS) -fpermissive

Alternatively you could have done this when configuring libgfx with:


cd ../libgfx
./configure CXXFLAGS='-fpermissive'
cd ../mixkit/

If you do it this way then you’ll get warnings instead of errors.

Now you can build with:


make -C src

qslim and qvis

Travel to the qslim tools directory:


cd ../tools/qslim

Here I need to add libfltk_gl to the linker commands in Makefile:


        $(CXX) -o qslim $(OBJS) $(LDFLAGS) $(LIBMIX) -lm -lfltk_gl
...
        $(CXX) -o qvis $(QVIS_OBJS) $(LDFLAGS) $(LIBMIX) $(GUI_LIBS) -lm -lfltk_gl

Then build with:


make

(those fpermissive warnings may show up again, but no problem)

Finally I can run the command line program qslim or the gui qvis. For some reason the qui qvis.app immediately closes if I double click on it. But I can run it by issuing:


./qvis.app/Contents/MacOS/qvis 

where I’m then prompted to load a .smf file.

or


./qvis.app/Contents/MacOS/qvis input.smf

You can call the command line program with:


./qslim -t 1000 -M smf -q 2>/dev/null

which spills the .smf file to stdout

It seems .smf format is the same as .obj, at least if there are only vertices and triangular faces. So, you can compose—a rather long—bash oneliner that simplifies an input.obj file to an output.obj file:


grep "^[vf] " input.obj | sed -e "s/^f *\([0-9][0-9]*\)\/[^ ]*  *\([0-9][0-9]*\)\/[^ ]*  *\([0-9][0-9]*\)\/.*/f \1 \2 \3/g" | ./qslim -t 1000 -M smf -q 2>/dev/null | grep "^[vf]" > output.obj

qslim/filters

I also built the “filters” (converters?) with:


cd ../filters
make

Note that ply2smf only acts on stdin and stdout so call it with:


cat input.ply | ./ply2smf >output.smf

Update: I found an easier way to setup the configure script and ensure that all macports libraries are found:


env CPPFLAGS="-I/opt/local/include -fpermissive" LDFLAGS="-L/opt/local/lib" ./configure

Macports Boost still incompatible with modern gcc compilers

Wednesday, May 8th, 2013

I recently ran into a well known issue with the macports installation of the boost library. It seems that when you issue:


sudo port install boost

you’re getting binaries of a version of boost compiled using the default compiler g++-apple-4.2. This is version of the library is unfortunately not compatible with any of the modern versions of gcc. For example this small program compiles and links correctly using g++-mp-4.7 but crashes at runtime.


#include <boost/program_options.hpp>
int main(int argc, char* argv[])
{
    boost::program_options::positional_options_description positional;
    return 0;
}

Running the code produces:


.main(33755) malloc: *** error for object 0x10f73b880: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

To fix this I forced macports to reinstall boost using my compiler of choice (g++-mp-4.7). On my computer this took 20+ minutes


sudo port -ns upgrade --force boost configure.compiler=macports-gcc-4.7

This resolves the issue above, but only for g++-mp-4.7, if I now compile my small test program using g++-apple-4.2 it fails in the same way (at least its mutually consistent).

Preview crashes when reopening PDFs created with LaTeX

Sunday, March 17th, 2013

To typeset documents I use pdflatex. I edit my tex files using vim and build the pdfs using a makefile. At the end of my make sequence I like to have:


open my.pdf

Which on my mac causes preview to open my pdf document.

When I recompile and this command runs, sometimes preview just focuses the already open document, but other times it opens a new window. I haven’t backwards engineered how it decides which to do, but it might be correlated with the amount of change in between. In any case, Preview recently has been crashing when it tries to open the same document in a new window. For small, short-term articles this is not so annoying. But now, writing my t****s, I’m really getting frustrated.

I wrote an applescript to replace the open command above. First you’ll need to enable applescript for Preview.app. Then you can save the following in preview.scpt.


on run argv
	set file_name to item 1 of argv
	try
		tell application "Preview"
			activate
			set open_already to false
			repeat with this_doc in every document
				set open_already to open_already or (name of this_doc as string is equal to file_name)
				if open_already then
					return "open already"
				end if
			end repeat
			if not open_already then
				open (do shell script "pwd") & "/" & file_name
				return ""
			end if
		end tell
	on error errMsg
		return errMsg
	end try
end run

You can run with:


osascript preview.scpt my.pdf

The rerun to see that no action is taken.

Backup DVD of television show to .mkv files

Sunday, March 3rd, 2013

I bought some DVDs of a german tv show. With my fancy macbook air, I unfortunately have no way to play them: no DVD drive!

So I dusted off my old laptop and installed vobcopy then I copied each dvd first to the old laptop from the disks using:


vobcopy -m

Then I copied these over to my macbook air. But these are just the raw dvd files (VIDEO_TS/*.VOB), which are rather large and unwieldy. To convert these to .mkv files I know to use Handbrake, but since I want to extract each of the 3 or 4 episodes per DVD, setting up Handbrake for each episode turned out to be too tedious. The presets in Handbrake don’t include options to extract all audio channels and all subtitles by default. Instead I found a ruby script call hb.rb which can set up batch jobs.

So finally to extract my episodes with all subtitles and all audio channels in tact I used:

./hb.rb --verbose --input ~/Downloads/IM_ANGESICHT_DES_VERBRECHENS_D2 --output "~/Downloads/#title#_#pos#.mkv" --min-length 00:10:00 --max-length 00:50:00 --skip-duplicates --audio-copy --skip-commentaries --only-first-track-per-language --autocrop

Scroll a bit in safari window, take screenshot repeat

Friday, February 22nd, 2013

Here’s an applescript I used to make a series of screen captures of scrolling through a web page in safari:


tell application "Safari"
	activate
	set sc to 0
	repeat
		set thescript to "if((window.pageYOffset + window.innerHeight)<document.body.clientHeight)
		{
    	window.scrollBy(0,10); // horizontal and vertical scroll increments
		}"
		do JavaScript thescript in current tab of first window
		set imagePath to (path to desktop as text) & "screenCapture_" & my zero_pad(sc, 6) & ".png"
		delay 1.5
		do shell script "screencapture -o -mx -T0 " & quoted form of POSIX path of imagePath
		delay 0.5
		set sc to sc + 1
	end repeat
	
end tell

on zero_pad(value, string_length)
	set string_zeroes to ""
	set digits_to_pad to string_length - (length of (value as string))
	if digits_to_pad > 0 then
		repeat digits_to_pad times
			set string_zeroes to string_zeroes & "0" as string
		end repeat
	end if
	set padded_value to string_zeroes & value as string
	return padded_value
end zero_pad

Source

Install ETH Fonts for LaTeX on Mac OS X

Thursday, February 7th, 2013

This turned out to be quite difficult.

I installed TexLive using macports.

If you download the ETH letter LaTeX templates and try to compile you will get an error like:


! I can't find file `letr8t'.
<*> ...:=ljfour; mag:=1; nonstopmode; input letr8t
                                                  
Please type another input file name
! Emergency stop.
<*> ...:=ljfour; mag:=1; nonstopmode; input letr8t
                                                  
Transcript written on mfput.log.
grep: letr8t.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input letr8t' failed to make letr8t.tfm.
kpathsea: Appending font creation commands to missfont.log.
! Font \xiiiv=letr8t at 8.5pt not loadable: Metric (TFM) file not found.
 
                   \relax 
l.112 \newfont{\xiiiv}{letr8t at 8.5pt}

This is complaining that you don’t have the ETH fonts installed. These are a pain to install.

Unzip into your macports texmf folder:


sudo unzip ETHLfnts.zip -d /opt/local/share/texmf/

Create a hash for the new files:


sudo texhash

If you try to compile brief2.tex now you will get an error:


kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 letb8r
mktexpk: don't know how to create bitmap font for letb8r.
mktexpk: perhaps letb8r is missing from the map file.
kpathsea: Appending font creation commands to missfont.log.
(see the transcript file for additional information)
!pdfTeX error: pdflatex (file letb8r): Font letb8r at 600 not found
 ==> Fatal error occurred, no output PDF file produced!

Open and append:


p +let.map

Now compiling should give you the error:


gsftopk: fatal: map file `let.map' not found.
mktexpk: don't know how to create bitmap font for letb8r.
mktexpk: perhaps letb8r is missing from the map file.
kpathsea: Appending font creation commands to missfont.log.
(see the transcript file for additional information)
!pdfTeX error: pdflatex (file letb8r): Font letb8r at 600 not found
 ==> Fatal error occurred, no output PDF file produced!

Create the file /opt/local/etc/texmf/ethfonts.cfg and add the line:


Map let.map

Update maps listing:


sudo updmap-sys

Now if you should get an error like:


ERROR:  The following map file(s) couldn't be found:
	let.map (in /opt/local/var/db/texmf/web2c/updmap.cfg)

If you try to compile brief2.tex you’ll get an error like:


gsftopk: fatal: map file `let.map' not found.
mktexpk: don't know how to create bitmap font for letb8r.
mktexpk: perhaps letb8r is missing from the map file.
kpathsea: Appending font creation commands to missfont.log.
(see the transcript file for additional information)
!pdfTeX error: pdflatex (file letb8r): Font letb8r at 600 not found
 ==> Fatal error occurred, no output PDF file produced!

So, copy let.map to your local texlive directory:


mkdir -p ~/.texlive2012/texmf-var/fonts/map/dvips/updmap/
cp /opt/local/share/texmf/maps/let.map ~/.texlive2012/texmf-var/fonts/map/dvips/updmap/

Update maps listing:


sudo updmap-sys

Now you should be able to successfully build:


pdflatex brief2

Empty trash without Preview (secretly) blocking

Thursday, January 24th, 2013

I run into this problem all the time. Even though Preview.app is not open, when I empty the trash I get warnings like:


The operation can't be completed because the item "some.pdf" is in use.

I’m not sure how it happens. But it seems some instance of Preview continues to run even after quitting or force quitting. I found this out by issuing:


sudo lsof ~/.Trash/some.pdf

This showed:


COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
Preview 73409  ajx  txt    REG   14,2 18966290 4989399 /Users/ajx/.Trash/some.pdf

Then I knew to issue:


kill 73409

Then I could empty the trash with no errors.

FTDI’s libftd2xx.1.2.2 broken for macbook air running 10.7.4 (workaround)

Friday, December 21st, 2012

I recently got my device working on my iMac at work using the libftd2xx.1.2.2 available from the drivers page of FTDI. Unfortunately the code I wrote that worked with that version of the library on my iMac did not work on my macbook air (despite running the same mac os x 10.7). My problem was that FT_Open was returning -1, which as far as I can tell is not a valid FT_STATUS enum value.

After a (not so) brief stint trying to get the libftdi open source library to work (I gave up because it was slow and crashed on ftdi_usb_close and ftdi_usb_reset), I tried to see if any of the old releases of libftd2xx would work for me. I tried all I could find and report the following:


Name                    Source   Problem
libftd2xx.1.1.0.dylib,  macports,          random "bus error 10" after ~30secs (otherwise pretty good)
libftd2xx.0.1.7.dylib,  D2xx drivers page, "Error FT_ListDevices(18)" and reading garbage occasionally
libftd2xx.1.0.4.dylib,  D2xx hidden page,  reading occasional garbage
libftd2xx.1.1.0.dylib,  D2xx hidden page,  "bus error 10" after ~30secs (otherwise pretty good)
libftd2xx.1.1.12.dylib, D2xx Drivers page, FT_Open(-1)
libftd2xx.1.2.2.dylib,  D2xx Drivers page, FT_Open(-1)

As you can see, one of the sources is “D2xx hidden page”. I found this accidentally.

The version 1.1.0 seemed like the best bet. But like clockwork the device would send a Bus error: 10 and crash after 30 seconds. I flipped a bunch of switches and toggled a bunch of comments and I think I found the issue.

I was reading in a tight loop using something like:


ftStatus = FT_Read(ftHandle, buffer, BUF_SIZE, &dwRxSize);

But what works is to do something like:


ftStatus = FT_GetStatus(ftHandle, &dwAmountInRxQueue, &dwAmountInTxQueue, &dwEventStatus);
if(dwAmountInRxQueue)                                      
{                                                          
  ftStatus = FT_Read(ftHandle, buffer, (dwAmountInRxQueue<BUF_SIZE?dwAmountInRxQueue:BUF_SIZE), &dwRxSize);
} 

I understand why the second is better, but I don’t understand why the first should crash. In any case, my device has been running with no problems for going on 8 minutes. So I’m happy again.

FTDI FT_Read from usb lag

Friday, December 21st, 2012

Yesterday, we hunted down a problem using FTDI’s D2XX drivers on my mac that was causing reading from our device to lag unevenly. We timed our reading routines and couldn’t find where we were losing framerate. Finally we found two issues, both fixed by changing parameters immediately after opening the device:

Originally we had


FT_SetTimeouts(ftHandle, 100, 100);

And we should have had


FT_SetTimeouts(ftHandle, 1, 1);

This function controls the maximum wait time during any call to FT_Read and FT_write.

Finally, the major cause of the lag was the absence of the following:


FT_SetUSBParameters(ftHandle, 64,64))

This defines the amount of data read and written each time from and to the device in bytes. It seems the default values were 4096 bytes. Our device sends a small amount of data at high frequency, so this number was way to high and was the major bottleneck causing the lag.

MATLAB mex file with boost (e.g. when using CGAL)

Friday, December 7th, 2012

On my laptop I have MATLAB2011b and I was able to compile a mex function using CGAL (and by dependency boost), just fine. When I tried this code on my iMac at work, the code compiled fine, but at runtime matlab crashed somewhere deep inside Cgal and boost:


[  0] 0x00000001000e4e46 /Applications/MATLAB_R2012b.app/bin/maci64/libmwfl.dylib+00036422 _ZN2fl4diag15stacktrace_base7captureERKNS0_14thread_contextEm+000150
[  1] 0x00000001000e5af1 /Applications/MATLAB_R2012b.app/bin/maci64/libmwfl.dylib+00039665 fl_diag_terminate+000321
[  2] 0x00000001000e7c34 /Applications/MATLAB_R2012b.app/bin/maci64/libmwfl.dylib+00048180 _ZN2fl4diag13terminate_logEPKcRKNS0_14thread_contextE+000100
[  3] 0x00000001008e125e /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00315998 mnTrapCtrlc+000254
[  4] 0x00000001008e2d24 /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00322852 _Z32mnRunPathDependentInitializationv+003492
[  5] 0x00000001008e313d /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00323901 _Z32mnRunPathDependentInitializationv+004541
[  6] 0x00000001008e37f5 /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00325621 _Z32mnRunPathDependentInitializationv+006261
[  7] 0x00000001008e3aa1 /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00326305 mnSIGABRTHandler+000129
[  8] 0x00007fff90d64cfa                  /usr/lib/system/libsystem_c.dylib+00666874 _sigtramp+000026
[  9] 0x00007fff6332b6f8                  /usr/lib/system/libsystem_c.dylib+18446744072944523000
[ 10] 0x00007fff90d03a7a                  /usr/lib/system/libsystem_c.dylib+00268922 abort+000143
[ 11] 0x0000000121634c3e              /opt/local/lib/gcc43/libgcc_s.1.dylib+00060478 uw_init_context_1+000142
[ 12] 0x0000000121635058              /opt/local/lib/gcc43/libgcc_s.1.dylib+00061528 _Unwind_Resume+000072
[ 13] 0x000000012106e2da /Users/ajx/Documents/volume/matlab/peeling/peeling.mexmaci64+00045786 mexFunction+001450
[ 14] 0x000000010550deca /Applications/MATLAB_R2012b.app/bin/maci64/libmex.dylib+00065226 mexRunMexFile+000090
[ 15] 0x0000000105509a29 /Applications/MATLAB_R2012b.app/bin/maci64/libmex.dylib+00047657 _ZN7Mfh_mex30runMexFileWithSignalProtectionEiPP11mxArray_tagiS2_+000137
[ 16] 0x000000010550b038 /Applications/MATLAB_R2012b.app/bin/maci64/libmex.dylib+00053304 _ZN7Mfh_mex13dispatch_fileEiPP11mxArray_tagiS2_+000232
[ 17] 0x00000001009dab43 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_dispatcher.dylib+00314179 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+000499
[ 18] 0x0000000100d8b5b2 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+03278258 _ZN20ResolverFunctionDesc12CallFunctionEiPP11mxArray_tagiS2_+000914
[ 19] 0x0000000100d9287f /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+03307647 _ZN8Resolver13CallMFunctionEiiP10_m_operandP17m_operand_storageiS1_S3_Pi+001679
[ 20] 0x0000000100d934e6 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+03310822 _Z22inResolveMFunctionCallP16_m_function_desciiP10_m_operandP17m_operand_storageiS2_S4_PiP13inMarshalTypeiPK19mpsTypeSequenceNlhsPFP11mxArray_tagiE+000598
[ 21] 0x0000000100bc9b4f /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+01436495 _ZN9accelImpl13MFunctionCallEPP8_accelOp+000527
[ 22] 0x0000000100bf4b7e /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+01612670 _ZN9accelImpl4ExecEv+000286
[ 23] 0x0000000100bf4c3b /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+01612859 _ZNK9accelCode4CallEP13inMarshalTypePi+000091
[ 24] 0x0000000100d39f16 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+02944790 _ZN5inJit17ExecuteHotSegmentEP15_inJitAccelInfoP7opcodesPiPl+001654
[ 25] 0x0000000100b24361 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00758625 _Z16inEnterDebugModeN5boost8functionIFvvEEEb+012273
[ 26] 0x0000000100b29c1c /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00781340 _Z18protected_inInterp12inDebugCheckii7opcodesPV15inPcodeNest_tagPl+000140
[ 27] 0x0000000100b2614e /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00766286 _Z16inEnterDebugModeN5boost8functionIFvvEEEb+019934
[ 28] 0x0000000100b27630 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00771632 _Z26inExecuteMFunctionOrScriptP6Mfh_mpb+000688
[ 29] 0x0000000100b9482a /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+01218602 _Z10inRunMfileiPP11mxArray_tagiS1_P6Mfh_mpP15inWorkSpace_tag+001530
[ 30] 0x00000001009dab43 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_dispatcher.dylib+00314179 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+000499
[ 31] 0x0000000100b76a5a /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+01096282 _Z19inDispatchFromStackiPKcii+001034
[ 32] 0x0000000100b02979 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00620921 inCallFcnFromReference+000265
[ 33] 0x0000000100b23125 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00753957 _Z16inEnterDebugModeN5boost8functionIFvvEEEb+007605
[ 34] 0x0000000100b29c1c /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00781340 _Z18protected_inInterp12inDebugCheckii7opcodesPV15inPcodeNest_tagPl+000140
[ 35] 0x0000000100b2614e /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00766286 _Z16inEnterDebugModeN5boost8functionIFvvEEEb+019934
[ 36] 0x0000000100b27630 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00771632 _Z26inExecuteMFunctionOrScriptP6Mfh_mpb+000688
[ 37] 0x0000000100b9482a /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+01218602 _Z10inRunMfileiPP11mxArray_tagiS1_P6Mfh_mpP15inWorkSpace_tag+001530
[ 38] 0x00000001009dab43 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_dispatcher.dylib+00314179 _ZN8Mfh_file11dispatch_fhEiPP11mxArray_tagiS2_+000499
[ 39] 0x0000000100b62904 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+01014020 _Z23inEvalPcodeHeaderToWordP15_memory_contextiPP11mxArray_tagP12_pcodeheaderP6Mfh_mpj+000260
[ 40] 0x0000000100b1c162 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00725346 _Z25in_local_call_with_setjmpIN5boost3_bi6bind_tIvPFvP15_memory_contextPiPP11mxArray_tagP12_pcodeheaderjENS1_5list5INS1_5valueIS4_EENS0_3argILi1EEENSG_ILi2EEENSE_ISA_EENSE_IiEEEEEEE17inExecutionStatusT_S5_S8_b+000082
[ 41] 0x0000000100b187f5 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00710645 _ZN7EvalLog6setLogEiPP11mxArray_tagiS2_+003381
[ 42] 0x0000000100b18b75 /Applications/MATLAB_R2012b.app/bin/maci64/libmwm_interpreter.dylib+00711541 _ZN7EvalLog6setLogEiPP11mxArray_tagiS2_+004277
[ 43] 0x000000010640058e /Applications/MATLAB_R2012b.app/bin/maci64/libmwbridge.dylib+00058766 _Z28evalCommandWithLongjmpSafetyPKc+000094
[ 44] 0x0000000106400d8b /Applications/MATLAB_R2012b.app/bin/maci64/libmwbridge.dylib+00060811 _Z28evalCommandWithLongjmpSafetyRKSbItSt11char_traitsItESaItEE+000043
[ 45] 0x000000010640181d /Applications/MATLAB_R2012b.app/bin/maci64/libmwbridge.dylib+00063517 _Z8mnParserv+001021
[ 46] 0x00000001008c4139 /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00196921 _ZN11mcrInstance30mnParser_on_interpreter_threadEv+000041
[ 47] 0x000000010089e76b /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00042859 _ZN3mcr7runtime17InterpreterThread4Impl17InvocationRequest3runEv+000523
[ 48] 0x000000010089e925 /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00043301 _ZN3mcr7runtime17InterpreterThread4Impl26invocation_request_handlerEl+000053
[ 49] 0x000000010042f574 /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00107892 _ZN10eventqueue18UserEventQueueImpl5flushEv+000756
[ 50] 0x000000010042f79a /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00108442 _ZN10eventqueue8ReadPipeEib+000026
[ 51] 0x000000010042df26 /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00102182 _ZN10eventqueue18UserEventQueueImpl9selectFcnEb+000326
[ 52] 0x0000000107d26a9d /Applications/MATLAB_R2012b.app/bin/maci64/libmwuix.dylib+00170653 _ZN21uix_nodisplay_ppeHook16pollingDuringFcnEb+000045
[ 53] 0x00000001004d71b2 /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00795058 _ZSt8for_eachIN9__gnu_cxx17__normal_iteratorIPN5boost8weak_ptrIN4sysq10ws_ppeHookEEESt6vectorIS6_SaIS6_EEEENS4_8during_FIS6_NS2_10shared_ptrIS5_EEEEET0_T_SH_SG_+000162
[ 54] 0x00000001004d8dab /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00802219 _ZN4sysq12ppe_for_eachINS_8during_FIN5boost8weak_ptrINS_10ws_ppeHookEEENS2_10shared_ptrIS4_EEEEEET_RKS9_+000203
[ 55] 0x00000001004d592c /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00788780 _ZN4sysq19ppePollingDuringFcnEb+000092
[ 56] 0x00000001004d5ac7 /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00789191 _ZN4sysq11ppeMainLoopEiib+000119
[ 57] 0x00000001004d5c94 /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00789652 _ZN4sysq11ppeLoopIfOKEiib+000132
[ 58] 0x00000001004d5e34 /Applications/MATLAB_R2012b.app/bin/maci64/libmwservices.dylib+00790068 _ZN4sysq20processPendingEventsEiib+000132
[ 59] 0x000000010089ea9f /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00043679 _ZN3mcr7runtime17InterpreterThread4Impl14process_eventsERKN5boost10shared_ptrIS2_EE+000223
[ 60] 0x000000010089f2ca /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00045770 _ZN3mcr7runtime17InterpreterThread4Impl3runERKN5boost10shared_ptrIS2_EEPNS2_12init_contextE+000282
[ 61] 0x0000000100897176 /Applications/MATLAB_R2012b.app/bin/maci64/libmwmcr.dylib+00012662 _Z26run_init_and_handle_eventsPv+000054
[ 62] 0x00007fff90d108bf                  /usr/lib/system/libsystem_c.dylib+00321727 _pthread_start+000335
[ 63] 0x00007fff90d13b75                  /usr/lib/system/libsystem_c.dylib+00334709 thread_start+000013

At first I thought it was a problem of compiling against the CGAL that came with macports rather than a version inside on matlab. But actually it seems matlab no longer contains the libCGAL libraries. I did however see the boost libraries there. When I checked the libraries of my mex file using:


otool -L myfunction.mexmaci64

I saw:


myfunction.mexmaci64:
	/opt/local/lib/libCGAL.10.dylib (compatibility version 10.0.0, current version 10.0.0)
	/opt/local/lib/libCGAL_Core.10.dylib (compatibility version 10.0.0, current version 10.0.0)
	/opt/local/lib/libgmp.10.dylib (compatibility version 11.0.0, current version 11.5.0)
	/opt/local/lib/libmpfr.4.dylib (compatibility version 6.0.0, current version 6.1.0)
	/opt/local/lib/libboost_thread-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libboost_system-mt.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libmx.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libmat.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libmex.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.17.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
	/opt/local/lib/gcc47/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

libboost_*-mt are the boost libraries that come from macports. Inside of matlab these are just libboost_* (without the -mt). After switching my make file to link against these:


-L$MATLAB/bin/maci64/ -lboost_thread -lboost_system

I used otool again and confirmed that I linked against matlab’s boost:


myfunction.mexmaci64:
	/opt/local/lib/libCGAL.10.dylib (compatibility version 10.0.0, current version 10.0.0)
	/opt/local/lib/libCGAL_Core.10.dylib (compatibility version 10.0.0, current version 10.0.0)
	@rpath/libgmp.3.dylib (compatibility version 8.0.0, current version 8.1.0)
	@rpath/libmpfr.1.dylib (compatibility version 3.0.0, current version 3.2.0)
	@rpath/libboost_thread.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libmx.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libmat.dylib (compatibility version 0.0.0, current version 0.0.0)
	@rpath/libmex.dylib (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.17.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
	/opt/local/lib/gcc47/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

I tried running my mex file and indeed this worked.

Update: This also happens when calling mex directly. Somehow matlab still finds the wrong boost libs.