The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   Library not loaded? (http://hintsforums.macworld.com/showthread.php?t=83800)

hayne 01-13-2008 10:12 PM

Quote:

Originally Posted by olifu02 (Post 441896)
Also, after that had installed i tried the second command you had said and this was what it said

Olson% sudo ln -s /sw/lib/gcc4.2/lib/libgfortran.2.dylib /usr/local/lib/libgfortran.2.dylib
ln: /usr/local/lib/libgfortran.2.dylib: File exists


Please show us the results of the following command:

ls -l /usr/local/lib/libgfortran.2.dylib

olifu02 01-14-2008 12:33 AM

Here are the results for the that command:

Olson% ls -l /usr/local/lib/libgfortran.2.dylib
lrwxr-xr-x 1 root wheel 38 Jan 12 15:17 /usr/local/lib/libgfortran.2.dylib -> /sw/lib/gcc4.2/lib/libgfortran.2.dylib

nijm 01-14-2008 03:39 AM

I'm wondering, what version of os x do you have? If you have 10.5, did you install fink via bootstrap? If the fink install of gcc42 didn't finish cleanly, then you should assume that the install of gcc42 is broken. This should be the first thing you address, that is, you can't expect anything to work before step one is executed properly. Also, does /sw/lib/gcc4.2/lib/libgfortran.2.dylib exist? What does otool -L tell you about it if it does?

olifu02 01-14-2008 03:30 PM

I reinstalled Fink. Used the Fink Commander to update my Fink and saw that gcc42 was installed. So i installed using FinkCommander and that did successfully this time. Did that second command which you had said and now it works. Thank you so much for your help.

olifu02 11-06-2009 09:17 AM

Well same problem...new mac...I got a brand new imac and im trying to install the same modelfree program to this new mac with snow leopard. I was following the directions but i find that fink must be bootstrapped to work with leopard so i think i did it properly but not sure what i have to download to get this problem to work. I already have gcc4.2 that came with xcode. The error im getting this time is:

dyld: Library not loaded: /usr/local/lib/libgfortran.3.dylib
Referenced from: /Users/Andrew/Documents/modelfree4_mac/Intel/./modelfree4
Reason: image not found
Trace/BPT trap


Thanks for your help.

nijm 11-06-2009 05:07 PM

Type this:
ls -l /usr/local/lib/libgfortran.3.dylib

What's the output?

olifu02 11-09-2009 10:05 AM

ls: /usr/local/lib/libgfortran.3.dylib: No such file or directory

olifu02 11-09-2009 03:14 PM

i dont even have a usr/local folder

nijm 11-09-2009 03:19 PM

That tells a lot.

1) Dowload this

2) Do a time machine backup right now in case my instructions were wrong or confusing, or if you mess it up.

3) Unzip. It expands into a directory named usr. Inside is the usual /usr/local structure. Copy all that stuff into your /usr/local subdirectories on your mac HD. You can use rsync if you don't want to cut and paste into each sub dir. For that:
Code:

cd <the dir named usr that the tar.gz made when you unzipped, not your system /usr>
sudo rsync -auv ./ /usr

This should copy the contents of your untarred usr dir into your /usr dir on your mac HD.

This is what I did when ROOT wouldn't compile on Snow Leopard. It got everything working again.

I don't know if modelfree4 wants x86_64 or i386 binaries. The i386 are in usr/local/lib/i386. If your linker complains of /usr/local/lib/libgfortran.3.dylib being wrong architecture after you copy all this stuff into /usr/local, then you might need to move stuff around a bit or make some soft links until it works, but it should work in the end. Hopefully you don't have to go there.

nijm 11-09-2009 03:21 PM

Oh, you don't have /usr/local? Well, then just copy the the usr/local from the tar ball right into /usr. You should be good to go after that.

olifu02 11-09-2009 03:46 PM

I did that...copied the contents of that into a /usr/local directory and now when i run my program i get the error

dyld: Library not loaded: /usr/local/lib/libgfortran.3.dylib
Referenced from: /Users/Andrew/Documents/modelfree4_mac/Intel/./modelfree4
Reason: no suitable image found. Did find:
/usr/local/lib/libgfortran.3.dylib: mach-o, but wrong architecture
/usr/local/lib/libgfortran.3.dylib: mach-o, but wrong architecture
Trace/BPT trap
[pcp018059pcs:~/Docu

nijm 11-09-2009 06:05 PM

So you probably need the i38 binaries I mentioned.

You can use lipo to make a universal 64/32 binary from the x86_64 binary in /usr/local/lib, and the i386 (32 bit) binary in /usr/local/lib/i386.

Here's how (read the manpage on lipo if you get confused, it's pretty straight forward as manpages go):

Code:

cd /usr/local
lipo lib/libgfortran.3.dylib lib/i386/libgfortran.3.dylib -create -output ./libgfortran.3.dylib
mv lib/libgfortran.3.dylib lib/gfortran.3.SAVE_x86_64.dylib
mv ./libgfortran.3.dylib lib/libgfortran.3.dlyb

You might need to do it with sudo.
If this new dual architecture lib works for you, you might want to go through and do it to all the libs that exist in both /usr/local/lib and /usr/local/lib/i386. That way, anything looking for fortran libs in /usr/local won't choke on the wrong architecture in the future.

olifu02 11-09-2009 06:15 PM

Worked like a charm....your awesome. To note though the spelling of your last command should by *.dylib and not *.dlyb


Thanks so much, saved me again.

nijm 11-09-2009 06:19 PM

ls -l /usr/local/lib/libgfortran.3.dylib

If it's there, then

Code:

file /usr/local/lib/libgfortran.3.dylib
This will tell you the architecture of the library.

If it's not there, then you probably have a typo or lost your file somewhere. Find it or make it again. I just downloaded modelfree4, made the dual binary how I just laid out, and ran modelfree4. It complained about mfin. So I think it works and is missing it's control file.
what do you get?

olifu02 11-10-2009 09:20 AM

i got it to work, thanks again.

Would you mind explaining what happened, id like to know just so i can get better at trouble shooting? Why it didnt work?

nijm 11-10-2009 02:16 PM

Why didn't it work? I don't know. Maybe you didn't get the name right when you copied or something. If that's not what you meant, then it first didn't work because os x doesn't put anything in /usr/local, or I guess doesn't even have /usr/local to begin with. That's for user stuff. So modelfree went looking for libgfortran.3.dylib there and it wasn't there. You can see a list of everything modelfree wants for it to run and where it will look by cd-ing into the dir where it lives and typing
Code:

otool -L modelfree4
You'll see a list of paths to libraries. If any of them are missing, then no go. Your program won't run. So they need to be there. However, there is one way to get past this most of the time if you have the library, but not where the executable expects to find it: In ~/.profile, put a line like this one
Code:

export DYLD_LIBRARY_PATH=/usr/local/lib:DYLD_LIBRARY_PATH
This environment variable is a colon separated list of paths where the linker should look for dylibs when you start programs from a login shell (when you open a new terminal window). This is where you but a list of paths where you have libraries, but are not default places for OS X to look for them. Usually (maybe always? not sure about this), if the linker can't locate a library that an executable wants (it's looking at the list you see when you run otool -L on an executable), then it will also look in the paths it finds in DYLD_LIBRARY_PATH.

Another, less general solution if you have a lib but it's not living where an executable expects it, is to make a soft link to the lib, in the place where the executable is looking. So, for example, if you happened to have libgfortran.3.dylib living in /sw/lib, you could either put that path in DYLD_LIBRARY_PATH, or you could type
Code:

ln -s /usr/local/lib/libgfortran.3.dylib /sw/lib
then there is basically a pointer called libgfortran.3.dylib to /sw/lib/libgfortran.3.dylib living /usr/local/lib. modelfree shouldn't be able to tell the difference.

The other reason it didn't work is because modelfree4 is compiled as a 32 bit executable (that's why the file command tells you it's i386 , the 80386 being the 32-bit predecessor of modern intel processors). The ilbgfortran.3.dylib in the gcc package you downloaded, or at least the one in /usr/local/lib, is compiled for intel 64-bit architecture (well, AMD64 really, you can read about this here, and also about the difference between 32 and 64 bit executables and libraries).

So, to get over the bumpy bits of transitioning all the executables and libraries from old (32) to new (64) architecture, Apple uses dual-architecture libraries and executables. They already were doing this when they changed from PPC to x86, now they added x86_64 to the bucket. These things (dual architecture binaries) are nothing more than container files with more than one binary inside (one for each included architecture). The lipo tool makes the container file by putting the separate binaries in one bag, so to speak, which the linker knows how to deal with.

I had a glass of wine, I hope that was coherent.

toodiesia 11-16-2009 08:05 PM

Library not loaded
 
Hi ,
I am using 2 versions of AIX
1st is AIX 5.1 and other is AIX 5.3 .
I have some library in AIX 5.3 that is mounted in AIX 5.1
I have compiled the library from AIX 5.1 and AIX 5.3 but in both the
cases it is not get loaded.

I got the following error in both the cases :-

ATTENTION: 0031-408 2 tasks allocated by LoadLeveler, continuing...
exec: 0509-036 Cannot load program ./hello because of the following
errors:
0509-130 Symbol resolution failed for /opt/CMS-64/lib/
libhpcshm.so because:
exec: 0509-036 Cannot load program ./hello because of the following
errors:
0509-130 Symbol resolution failed for /opt/CMS-64/lib/
libhpcshm.so because:
0509-136 Symbol __fd_select number 41 is not exported from
dependent module /usr/lib/libc.ashr_64.o.
0509-136 Symbol __fd_select number 41 is not exported from
dependent module /usr/lib/libc.ashr_64.o.
0509-130 Symbol resolution failed for /opt/CMS-64/lib/
libmpi.so because:
0509-136 Symbol __fd_poll number 53 is not exported from
dependent module /usr/lib/libc.ashr_64.o.
0509-136 Symbol __fd_select number 54 is not exported from
dependent module /usr/lib/libc.ashr_64.o.
0509-130 Symbol resolution failed for /opt/CMS-64/lib/
libmpi.so because:
0509-136 Symbol __fd_poll number 53 is not exported from
dependent module /usr/lib/libc.ashr_64.o.
0509-136 Symbol __fd_select number 54 is not exported from
dependent module /usr/lib/libc.ashr_64.o.
0509-150 Dependent module libmpi.so could not be loaded.
0509-150 Dependent module libmpi.so could not be loaded.
0509-026 System error: Cannot run a file that does not have a
valid format.
0509-026 System error: Cannot run a file that does not have a
valid format.
0509-192 Examine .loader section symbols with the
dump -Tv command.
0509-192 Examine .loader section symbols with the
dump -Tv command.


Can anybody tell me whats the problem.
LIBPATH is set properly.

thanks in advance............

olifu02 11-20-2009 03:29 PM

Same problem with new library needed, Ive tried those other suggestions but nothing has worked.

dyld: Library not loaded: /usr/local/lib/libg2c.0.dylib
Referenced from: /usr/local/garant-2.2/src/./garant
Reason: image not found
Trace/BPT trap

Do different compilers install different libraries. How does one know where to obtain these libraries? Thanks for your help again.


All times are GMT -5. The time now is 05:43 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.