Search code examples
cmatlabgccmex

mex doesn't recognize inline


I'm trying to compile a matlab wrapper for libdc1394 which is a library for firewire cameras. I get a strange error involving some inline functions in a header file. I'm working on ubuntu 12.04 with gcc-4.6. I've compiled other mex files with success. This wrapper was also difficult to compile in mac.

/usr/local/MATLAB/R2012b//bin/mex dc1394mex.c  `pkg-config --libs --cflags libdc1394-2` -o dc1394.mexa64

Warning: You are using gcc version "4.6.3-1ubuntu5)".  The version
         currently supported with MEX is "4.4.6".
         For a list of currently supported compilers see: 
         http://www.mathworks.com/support/compilers/current_release/

In file included from /usr/include/dc1394/dc1394.h:53:0,
                 from dc1394mex.c:23:
/usr/include/dc1394/register.h:47:1: error: unknown type name ‘inline’
/usr/include/dc1394/register.h:47:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dc1394_get_register’
/usr/include/dc1394/register.h:62:1: error: unknown type name ‘inline’
/usr/include/dc1394/register.h:62:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dc1394_set_register’
/usr/include/dc1394/register.h:82:1: error: unknown type name ‘inline’
/usr/include/dc1394/register.h:82:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dc1394_get_control_register’
/usr/include/dc1394/register.h:97:1: error: unknown type name ‘inline’
/usr/include/dc1394/register.h:97:29: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dc1394_set_control_register’
/usr/include/dc1394/register.h:117:1: error: unknown type name ‘inline’
/usr/include/dc1394/register.h:118:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dc1394_get_adv_control_register’
/usr/include/dc1394/register.h:133:1: error: unknown type name ‘inline’
/usr/include/dc1394/register.h:134:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dc1394_set_adv_control_register’
dc1394mex.c: In function ‘command_init_camera’:
dc1394mex.c:133:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
dc1394mex.c:152:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
dc1394mex.c: In function ‘dcframe_to_mxframe’:
dc1394mex.c:571:1: error: expected expression before ‘/’ token
dc1394mex.c:572:1: error: expected expression before ‘/’ token
dc1394mex.c:573:1: error: expected expression before ‘/’ token

    mex: compile of ' "dc1394mex.c"' failed.

make: *** [dc1394.mexa64] Error 1

Any ideas?


Solution

  • Well Simons proposal was correct. Only catch I didn't know was that you can't give cflags directly to mex. You have to alter your mexopts.sh file. Also I had to remove -ansi flag because it contradicts with c99.