MATLAB: Do I receive a link error about relocatable entries when trying to compile a C-MEX file on a Mac with MATLAB 7.0 (R14)

3.3entrieserrorgcclinkmacMATLABmexrelocatablerelocation

I am trying to compile a C-MEX function on Mac using GCC 3.3. My C-MEX function makes use of third-party libraries, and when I try compiling it with MEX, I receive the following error message:
ld: libvfbb.a(from_vax_r4.o) has local relocation entries in non-writable section (__TEXT,__symbol_stub1)
mex: link of 'bbdata.mexmac' failed.

Best Answer

This error message may occur when compiling code on a Mac with GCC 3.3.
To work around this issue, try editing the mexopts.sh file so that “-read_only_relocs suppress” is added to the LDFLAGS line. The mexopts.sh file is located in $MATLAB/bin, where $MATLAB is your root MATLAB directory.
The LDFLAGS line should subsequently look like:
LDFLAGS = -bundle -Wl,-flat_namespace -undefined suppress -read_only_relocs suppress
Related Question