Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

mex linking problem

31 views
Skip to first unread message

Vincent

unread,
May 26, 2009, 3:22:04 PM5/26/09
to
Hi folks,

I just happened to recompile some code I wrote 2 months ago and which was working fine but I'm now encountering some linking problem.

I use a MacPro with latest OS X, XCode and Matlab.

Two main changes occurred on my system in between the two compiles : upgraded from Matlab 2008a to 2009a and upgrade to XCode 3.0. It the compiler has trouble finding the frameworks. Here's the error output :

>> mex setDisplayMode.c
Undefined symbols:
"___CFConstantStringClassReference", referenced from:
__cfstring@0 in setDisplayMode.o
"_CGGetOnlineDisplayList", referenced from:
_mexFunction in setDisplayMode.o
"_CGConfigureDisplayMode", referenced from:
_mexFunction in setDisplayMode.o
"_IODisplayCreateInfoDictionary", referenced from:
_mexFunction in setDisplayMode.o
"_CGDisplayBestModeForParametersAndRefreshRate", referenced from:
_mexFunction in setDisplayMode.o
"_CFStringGetCStringPtr", referenced from:
_mexFunction in setDisplayMode.o
"_CFDictionaryGetValue", referenced from:
_mexFunction in setDisplayMode.o
"_CFDictionaryGetKeysAndValues", referenced from:
_mexFunction in setDisplayMode.o
"_CGCompleteDisplayConfiguration", referenced from:
_mexFunction in setDisplayMode.o
"_CGBeginDisplayConfiguration", referenced from:
_mexFunction in setDisplayMode.o
"_CGDisplayIOServicePort", referenced from:
_mexFunction in setDisplayMode.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

mex: link of ' "setDisplayMode.mexmaci"' failed.

??? Error using ==> mex at 218
Unable to complete successfully.

I call the frameworks using the following in the C code :

#include <ApplicationServices/ApplicationServices.h>
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/graphics/IOGraphicsTypes.h>
#include <IOKit/graphics/IOGraphicsLib.h>

I tried explicit paths and it didn't help.

Does anybody encountered the same problem or know how to solve this?

Thanks,

Vincent.

Vincent

unread,
May 26, 2009, 3:57:01 PM5/26/09
to
Example code that should work but give a linking error :

#include "mex.h"
#include <ApplicationServices/ApplicationServices.h>

void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
// Variables for getting the online displays
CGDisplayCount MAXDISPLAYS = 4;
CGDirectDisplayID onlineDspys[MAXDISPLAYS];
CGDisplayCount dspyCnt;
CGDisplayErr err;

// Get the displays ID
err = CGGetOnlineDisplayList( MAXDISPLAYS,
onlineDspys,
&dspyCnt );
}

Gives :

>> mex -v test.c
-> mexopts.sh sourced from directory (DIR = $HOME/.matlab/$REL_VERSION)
FILE = /Users/monkeylab2/.matlab/R2009a/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2009a.app
-> CC = gcc-4.0
-> CC flags:
CFLAGS = -fno-common -no-cpp-precomp -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -fexceptions
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2009a.app/bin/maci -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = g++-4.0
-> CXX flags:
CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB_R2009a.app/bin/maci -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
FFLAGS = -fexceptions -fbackslash
FDEBUGFLAGS = -gdwarf-2
FOPTIMFLAGS = -O
FLIBS = -L/Applications/MATLAB_R2009a.app/bin/maci -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = gcc-4.0
-> Link flags:
LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch i386 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2009a.app/extern/lib/maci/mexFunction.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmaci
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------

-> gcc-4.0 -c -I/Applications/MATLAB_R2009a.app/extern/include -I/Applications/MATLAB_R2009a.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "test.c"

-> gcc-4.0 -O -Wl,-twolevel_namespace -undefined error -arch i386 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2009a.app/extern/lib/maci/mexFunction.map -o "test.mexmaci" test.o -L/Applications/MATLAB_R2009a.app/bin/maci -lmx -lmex -lmat -lstdc++

Undefined symbols:
"_CGGetOnlineDisplayList", referenced from:
_mexFunction in test.o


ld: symbol(s) not found
collect2: ld returned 1 exit status

mex: link of ' "test.mexmaci"' failed.

??? Error using ==> mex at 218
Unable to complete successfully.

Anyone (mac users...) can compile that code?

Vincent.

Vincent

unread,
May 26, 2009, 4:45:03 PM5/26/09
to
Found out that this bug doesn't occur in Matlab R2008a. Submitted bug.
0 new messages