From: J. Ole Kaven on
I'm interested in reading .mat files in external c++ codes to expedite some of the work and be able to run it on a computing server. I've been reading up on how to do this at: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f14500.html#f25823

I've also made sure to update the ~/.bashrc file to link the appropriate libraries (see http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f19027.html).

The steps I went through in Matlab are the following:
1) mex -setup (option 3: ANSI compiler)
2) mex -f /usr/local/matlab/bin/matopts.sh matcreat.cpp
works fine, output as given in example
3) mex -f /usr/local/matlab/bin/matopts.sh matdgns.c
here I get the following error:
"matdgns.o: In function `diagnose':
matdgns.c:(.text+0x1d): undefined reference to `mexPrintf'
matdgns.c:(.text+0x44): undefined reference to `mexPrintf'
matdgns.c:(.text+0x6d): undefined reference to `mexPrintf'
matdgns.c:(.text+0x8c): undefined reference to `mexPrintf'
matdgns.c:(.text+0xac): undefined reference to `mexPrintf'
matdgns.o:matdgns.c:(.text+0xdf): more undefined references to `mexPrintf' follow
collect2: ld returned 1 exit status

mex: link of ' "matdgns"' failed."

I've tried to compile using option 2 in mex -setup (.../gccopts.sh), which at least compiles, but results in a segmentation fault upon execution

The question then is pretty obvious:
What am I doing wrong? Any help would be appreciated!
(I've read the following thread, which doesn't solve my problem: http://www.mathworks.com/matlabcentral/newsreader/view_thread/257301#669415)

Thanks in advance,
Ole