Maverick - R2014a - LoadLibrary Error - loaddefinedlibrary

4 views (last 30 days)
Does anyone have any insight on how to resolve this problem?
I'm trying to build a thunk.dylib for use in calling a .dylib in matlab. This method works in windows 7, so its an operating system specific problem. Debugger won't step in to the function loaddefinedlibrary for further investigation. The symbolic link /opt/refprop/librefprop/librefprop.dylib does in fact exist. See below the matlab error output for info from terminal showing the links exists:
fyi thunk.m line 4 is the only command in the file.
Error using loadlibrary (line 422)
There was an error loading the library "/opt/refprop/librefprop.dylib"
dlopen(/opt/refprop/librefprop.dylib, 6): Symbol not found:
__gfortran_transfer_character_write
Referenced from: /opt/refprop/librefprop.dylib
Expected in: /Applications/MATLAB_R2014a.app/sys/os/maci64/libgfortran.3.dylib
in /opt/refprop/librefprop.dylib
Error in thunk (line 4)
loadlibrary('librefprop','header.h','mfilename','rp_proto64')
Caused by:
Error using loaddefinedlibrary
dlopen(/opt/refprop/librefprop.dylib, 6): Symbol not found:
__gfortran_transfer_character_write
Referenced from: /opt/refprop/librefprop.dylib
Expected in: /Applications/MATLAB_R2014a.app/sys/os/maci64/libgfortran.3.dylib
in /opt/refprop/librefprop.dylib
Terminal output:
XXXXXXXX $ ls -all
total 200
drwxr-xr-x 9 nkampy wheel 306 Apr 10 10:02 .
drwxr-xr-x@ 5 nkampy wheel 170 Apr 10 09:08 ..
drwxr-xr-x 129 nkampy wheel 4386 Apr 10 09:08 fluids
-rwxr-xr-x 1 nkampy wheel 12655 Apr 10 09:59 header.h
lrwxr-xr-x 1 root wheel 31 Apr 10 09:10 librefprop.dylib -> /usr/local/lib/librefprop.dylib
-rwxr-xr-x 1 nkampy wheel 25008 Apr 10 10:02 librefprop_thunk_maci64.dylib
drwxr-xr-x 81 nkampy wheel 2754 Apr 10 09:08 mixtures
-rw-r--r-- 1 nkampy wheel 48385 Apr 10 10:02 rp_proto64.m
-rwxr-xr-x@ 1 nkampy wheel 310 Apr 10 10:02 thunk.m
XXXXXXX $ pwd
/opt/refprop
XXXXXXXXXXXXX $ ls -all
total 7216
drwxr-xr-x 24 root wheel 816 Apr 10 09:10 .
drwxr-xr-x 10 root wheel 340 Apr 9 21:42 ..
drwxr-xr-x 3 root wheel 102 Apr 4 2011 ImageMagick-6.6.9
drwxr-xr-x 4 root wheel 136 May 12 2012 ImageMagick-6.7.6
drwxr-xr-x 9 root wheel 306 Mar 29 2013 itcl4.0.0
-rw-r--r-- 1 root wheel 992256 Apr 10 09:10 librefprop.9.1.dylib
lrwxr-xr-x 1 root wheel 35 Apr 10 09:10 librefprop.dylib -> /usr/local/lib/librefprop.9.1.dylib
-r-xr-xr-x 1 root wheel 1419604 Mar 29 2013 libtcl8.6.dylib
-rwxr-xr-x 1 root wheel 4824 Mar 29 2013 libtclstub8.6.a
-r-xr-xr-x 1 root wheel 1239868 Mar 29 2013 libtk8.6.dylib
-rwxr-xr-x 1 root wheel 3464 Mar 29 2013 libtkstub8.6.a
drwxr-xr-x 4 root wheel 136 Mar 30 2013 pkgconfig
drwxr-xr-x 4 root wheel 136 Mar 29 2013 sqlite3.7.15.1
drwxr-xr-x 5 root wheel 170 Mar 29 2013 tcl8
drwxr-xr-x 19 root wheel 646 Mar 31 2013 tcl8.6
-rw-r--r-- 1 root wheel 7977 Mar 29 2013 tclConfig.sh
-rw-r--r-- 1 root wheel 771 Mar 29 2013 tclooConfig.sh
drwxr-xr-x 7 root wheel 238 Mar 29 2013 tdbc1.0.0
drwxr-xr-x 5 root wheel 170 Mar 29 2013 tdbcmysql1.0.0
drwxr-xr-x 5 root wheel 170 Mar 29 2013 tdbcodbc1.0.0
drwxr-xr-x 5 root wheel 170 Mar 29 2013 tdbcpostgres1.0.0
drwxr-xr-x 5 root wheel 170 Mar 29 2013 thread2.7.0
drwxr-xr-x 40 root wheel 1360 Mar 29 2013 tk8.6
-rw-r--r-- 1 root wheel 4334 Mar 29 2013 tkConfig.sh
XXXXXXXX $ pwd
/usr/local/lib

Accepted Answer

Nathan
Nathan on 23 Apr 2014
It is likely that a function in the libgfortran runtime library is not found in the MATLAB application directory, where it is expected. A possible workaround would be to use a soft (symbolic) link for the libgfortran.3.dylib.
1. If gfortran is installed on your machine, this DYLIB is located at /usr/local/lib/libgfortran.3.dylib
2. Rename the DYLIB file in the MATLAB application directory
3. Create a soft link for the DYLIB: ln -s /usr/local/lib/libgfortran.3.dylib /Applications/MATLAB_R2013b.app/sys/os/maci64/libgfortran.3.dylib
Restart MATLAB and try using the loadlibrary command to create the prototype file again. Do you still encounter the error message? If not, then the this is likely caused by a corrupt gfortran dynamic library in the MATLAB application directory.
in the case of using fink to install the gnu package on a mac its in the /sw folder. Otherwise the directions are the same.
A second way to resolve this is to add to the matlab search path in the startup file the location of the library.

More Answers (1)

Luis Pizarro
Luis Pizarro on 25 Apr 2014
Edited: Luis Pizarro on 25 Apr 2014
I did try Nathan's suggestion, but didn't work. I' using MATLAB2013a, Xcode 5.1, and gfortran-4.8.
I had the same/similar problem because MATLAB only supports gfortran-4.3. I found this installer for Mac but it didn't work on my 64-bit version.
I solved the issue by using an earlier version (4.2.3) which you can download here gfortran-4.2.3.dmg or from this list. MATLAB gave me a compilation warning though, but I could execute my gfortran program with no further issues.
  1 Comment
Theo Olsthoorn
Theo Olsthoorn on 7 Nov 2014
I had this problem when I ran fortran compiled stand alone programs from Matlab, i.e. MODFLOW and related programs, which I compiled on OSX some time ago. With R21014 I got an error message
"/Users/Theo/GRWMODELS/mflab/bin/mf2005.mac" mf2005.nam
dyld: lazy symbol binding failed: Symbol not found: __gfortran_transfer_character_write Referenced from: /Users/Theo/GRWMODELS/mflab/bin/mf2005.mac Expected in: /Applications/MATLAB_R2014a.app/sys/os/maci64/libgfortran.3.dylib
dyld: Symbol not found: __gfortran_transfer_character_write Referenced from: /Users/Theo/GRWMODELS/mflab/bin/mf2005.mac Expected in: /Applications/MATLAB_R2014a.app/sys/os/maci64/libgfortran.3.dylib
From this it is clear that the dylib that comes along with Matlab and is used by Matlab as default does not hold the desired function and so is not compatible. I, however, have the correct dylib at some other location on my OSX. So I renamed the version in the search dir used by Matlab and copied my old version of dylab to that directory. This solved the problem.
This solution seems very practicle and logical as well.
Regards Theo

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!