Unable to build a shared library

I run R2011b on Mac OSX10.6.8. When I try the users' guide example of shared library compilation and execute the command:
>> mbuild matrixdriver.c -L. -lmatrix -I. -v
the build process terminates immediatly with no error messages, just:
----------------------------------------------------------------
-> mbuildopts.sh sourced from directory (DIR = $PREF_DIR)
FILE = /Users/dan/.matlab/R2011b/mbuildopts.sh
----------------------------------------------------------------
-> TMW_ROOT = /Applications/MATLAB_R2011b.app
-> CC = gcc-4.2
-> CC flags:
CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -I/Applications/MATLAB_R2011b.app/extern/include -DUNIX -DX11
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2011b.app/runtime/maci64 -lmwmclmcrrt
arguments =
-> LD = gcc-4.2
-> Link flags:
LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bind_at_load
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
arguments = -L.
----------------------------------------------------------------
-> gcc-4.2 -c -I. -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -I/Applications/MATLAB_R2011b.app/extern/include -DUNIX -DX11 -O2 -DNDEBUG "matrixdriver.c"
-> gcc-4.2 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bind_at_load -framework CoreFoundation -L. -o matrixdriver.app/Contents/MacOS/matrixdriver matrixdriver.o -L/Applications/MATLAB_R2011b.app/runtime/maci64 -lmwmclmcrrt -lmatrix
----------------------------------------------------------------
The directory matrixdriver.app has been created and the files matrixdriver.app/Contents/MacOS/applauncher matrixdriver prelaunch
are also created.
I have set correctly the DYLD_LYBRARY_PATH for MCR.
When I try to execute in the Terminal window the command:
> .../work/libexample/matrixdriver.app/Contents/MacOS/matrixdriver
I get the message:
dyld: Library not loaded: @loader_path/libmatrix.dylib
Referenced from: .../work/libexample/matrixdriver.app/Contents/MacOS/matrixdriver
Reason: no suitable image found. Did find:
/System/Library/Frameworks/JavaVM.framework/JavaVM/libmatrix.dylib: stat() failed with errno=20
Trace/BPT trap
apparently the DYLD lib has not been correctly linked.
Can you provide any suggestion? best regards

 Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 14 Sep. 2011

0 Stimmen

Are you running the example on this page? If yes, you should have also run the following command to generate libmatrix.dylib:
mcc -B csharedlib:libmatrix addmatrix.m multiplymatrix.m
eigmatrix.m -v
You probably need to add the directory containing this library also to DYLD_LYBRARY_PATH.

Weitere Antworten (2)

Daniele Marini
Daniele Marini am 14 Sep. 2011

0 Stimmen

Indeed I have previously complide the library creating the files: libmatrix.c libmatrix.dylib libmatrix.exports libmatrix.h
then I run: mbuild matrixdriver.c -L. -lmatrix -I.
I open a Terminal and check the path:
DYLD_LIBRARY_PATH=/Applications/MATLAB/MATLAB_Compiler_Runtime/v716/runtime/maci64: /Applications/MATLAB/MATLAB_Compiler_Runtime/v716/sys/os/maci64: /Applications/MATLAB/MATLAB_Compiler_Runtime/v716/bin/maci64: /System/Library/Frameworks/JavaVM.framework/JavaVM: /System/Library/Frameworks/JavaVM.framework/Libraries XAPPLRESDIR=/Applications/MATLAB/MATLAB_Compiler_Runtime/v716/X11/app-defaults
and run the command:
my_work_directory/matrixdriver.app/Contents/MacOS/matrixdriver
getting the message:
dyld: Library not loaded: @loader_path/libmatrix.dylib Referenced from: /Users/dan/Documents/MATLAB/work/sharedlib/matrixdriver.app/Contents/MacOS/matrixdriver Reason: no suitable image found. Did find: /System/Library/Frameworks/JavaVM.framework/JavaVM/libmatrix.dylib: stat() failed with errno=20 Trace/BPT trap
any other suggestion? Daniele
Daniele Marini
Daniele Marini am 14 Sep. 2011

0 Stimmen

Oops. I have added the path to the compiled shared library and now it works! many thanks Daniele

Kategorien

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by