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)

olifu02 01-03-2008 10:15 AM

Library not loaded?
 
I am trying to install a program for my research and when i set the path and try and execute it i get this error

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

...I try and make that directory, it says permission denied.

Thanks in advance.

cwtnospam 01-03-2008 11:15 AM

The directory: /usr/local/lib/ should exist already. It probably doesn't have the file: libgfortran.2.dylib in it. What are you trying to install?

trevor 01-03-2008 01:04 PM

Quote:

Originally Posted by cwtnospam
The directory: /usr/local/lib/ should exist already.

Although /usr/local is present on all of my Macs, I'm pretty sure it's because I created it myself. I don't think it is correct that /usr/local will be present in a default install of OS X.

Quote:

Originally Posted by olifu02
...I try and make that directory, it says permission denied.

To create /usr/local/lib, use the commands
sudo mkdir /usr/local
sudo mkdir /usr/local/lib


However, just making the directory is not going to solve the problem. How did you install this 'modelfree4'? It's referencing dynamic libraries that you apparently don't have installed, which makes me think that it was not installed properly.

Trevor

Trevor

bb5ch39t 01-03-2008 01:11 PM

Can't be 100% sure, but that "libgfortran" sure looks like it might be part of the GNU Compiler Collection (GCC) Fortran run-time. I get this impression from the Google hits on libgfortran.

cwtnospam 01-03-2008 01:20 PM

Quote:

Originally Posted by trevor (Post 439157)
Although /usr/local is present on all of my Macs, I'm pretty sure it's because I created it myself. I don't think it is correct that /usr/local will be present in a default install of OS X.

It's on my Mac too, but I have no memory of creating it. Perhaps with some other application's install?

trevor 01-03-2008 01:25 PM

That might be correct. It's the traditional Unix place of putting things that the user installs themselves, instead of being part of the distro's collection of apps.

Trevor

brettgrant99 01-03-2008 03:59 PM

Someone else set it up for me, but I have gcc4.2 installed on my system. It is installed in /usr/local/gcc4.2. In the lib directory, not /usr/local/lib, libgfortran.2.dylib is in there, but it is just a link to another library.

I am not sure if Xcode installs gfortran. Do you have gcc installed on your machine? Have you done a search for the library?

You could try setting you DYLD_LIBRARY_PATH variable to point to it, if you can find the library, although that is a cludge.

Also, I find otool -L helpfull in making sure that your executable sees all of the libraries that you think it should see.

Good Luck,
Brett

nijm 01-04-2008 10:59 AM

try
Code:

locate libfortran
from a shell (i.e. from Terminal), and post what you get back. On my MacBook running 10.5.1 with Xcode installed, I only have libgfortran.2.dylib at
Code:

/sw/lib/gcc4.2/lib/fortran.2.dylib
this tells me that it is part of an install of gcc4.2 from fink, as /sw is the root directory for fink. Apparently, Xcode has nothing to do with it.

Sometimes, if you have the lib, but not in the location where some software is looking for it, you can make a symbolic link to it in the place where the software is looking for it. This usually works, unless the dylib itself is messed up. And as brettgrant99 said, try using otool -L on your executable, as well as your dylib. This will tell you where your executable looks for the dylib. Also, the dylib itself must have a working reference to itself in order for the linker to connect it to your executable at runtime, and running otool -L on the dylib will reveal if this is broken or not (that is, if you even have the dylib). You can post the result, and someone here should be able to interpret its meaning.

olifu02 01-11-2008 12:27 PM

when i try the locate libfortran nothing comes up. I also tried otool -L modelfree4 and this comes up...

otool: can't open file: modelfree4 (No such file or directory)

not sure what to do or install

thanks for the help

hayne 01-11-2008 12:35 PM

Quote:

Originally Posted by olifu02 (Post 441405)
I also tried otool -L modelfree4 and this comes up...

otool: can't open file: modelfree4 (No such file or directory)

otool is expecting you to supply the path to the executable file (if it isn't in the current folder), so you probably want to do:
Code:

otool -L /Users/Olson/Documents/Research/Modelfree/modelfree4_mac/Intel/modelfree4

olifu02 01-11-2008 02:08 PM

This is the printout of what hayne had suggested, not sure what it all means. Thanks hayne.

/Users/Olson/Documents/Research/Modelfree/modelfree4_mac/Intel/modelfree4:
/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib (compatibility version 1.0.0, current version 192.15.0)
/usr/local/lib/libgfortran.2.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.4)

nijm 01-11-2008 06:42 PM

Your otool output:

/Users/Olson/Documents/Research/Modelfree/modelfree4_mac/Intel/modelfree4:
/System/Library/Frameworks/vecLib.framework/Versions/A/vecLib (compatibility version 1.0.0, current version 192.15.0)
/usr/local/lib/libgfortran.2.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.4)

This means it looks for libgfortran at the path:

/usr/local/lib/libgfortran.2.dylib

But you probably don't have libgfortran, since locate didn't find it. You could try installing gcc42 with fink, then put a symbolic link pointing to /sw/lib/gcc4.2/lib/libgfortran.2.dylib at usr/local/lib/libgfortran.2.dylib.

That is, go to the fink website and download and install fink if you don't already have it. Once that is finished, go to terminal and type
Code:

sudo fink install gcc42
this will install gnu compiler collection version 4.2. Wait for this to finish, then
Code:

sudo ln -s /sw/lib/gcc4.2/lib/libgfortran.2.dylib /usr/local/lib/libgfortran.2.dylib
There should now be link at the location where modelfree4 is looking for it.

EDIT:
I just downloaded modelfree4 and tried it, got your error, then made the link I suggested above, and now modelfree4 starts and complains that there are no input files. I presume it must be working now, since I don't actually have any input files for it, and it gets far enough to complain about it :)
EDIT 2:
I found the test files that come with it, it's chugging away as I write.

olifu02 01-12-2008 03:05 PM

The fink website seems to be down, are there any other porting programs that are suitable? Also, what is gcc42 and where would i get it? Thanks for your help.

olifu02 01-12-2008 03:49 PM

I found Fink 0.8.1 but now which gcc do i download, the fortran one or just regular gcc?

nijm 01-12-2008 05:42 PM

Looks like fink is down for a few days. You could try macports. Or you can wait for fink to come back up, or you can dig around a bit, maybe you will find it. You want gcc 4.2. If you get fink going, you can run the command I posted above to get gcc 4.2:
Code:

sudo fink install gcc42
If this doesn't get that lib, then maybe you need gcc42-shlibs. Do
Code:

fink list gcc
among others, you should see the line:

gcc42-shlibs 4.2.2-1000 Shared libraries for gcc4

The first field is the name of the package. So:
Code:

sudo fink install <name of package>
will get the package you want installed.

olifu02 01-12-2008 06:36 PM

When i run that command "sudo fink install gcc42" it says

Olson% sudo fink install gcc42
Information about 1732 packages read in 1 seconds.
Failed: no package found for specification 'gcc42'!

Olson% fink list gcc
Information about 1732 packages read in 0 seconds.
avr-gcc 3.3.2-1 GNU GCC for ATMEL AVR micro controllers
broken-gcc 3.3-1 [virtual package representing a broken gcc compiler]
gcc2 2.95.2-0 [virtual package representing the gcc 2.95.2 compiler]
gcc2.95 2.95.2-0 [virtual package representing the gcc 2.95.2 compiler]
gcc3.1 3.1-0 [virtual package representing the gcc 3.1 compiler]
i gcc3.3 3.3-1819 [virtual package representing the gcc 3.3 compiler]
i gcc4.0 4.0.1-5363 [virtual package representing the gcc 4.0.1 compiler]

Does the gcc come with fink or my apple cd, becasue i cant find it anywhere on the net. Thanks again.

nijm 01-13-2008 05:20 AM

fink doesn't come with anything, it's package manager. It can list for you the software available for you in the fink repositories, and it can download, build, and install a package if you ask it to. I think you don't have all the repositories enabled, and gcc42 is not in the one's you do have enabled. So it won't list it, or be able to install it.

Why don't you get fink commander, a gui for fink. Once you start it (if it asks you to get the most recent version of FinkCommander at this point, this is a bug, ignore the request), go to preferences, and select the 'fink' heading. Then check the boxes:

'Use unstable packages'
'Use unstable cryptography packages*'

Click ok.

Now, in the search field in FinkCommander you can type gcc, and you will see a list of matching entries. Select gcc42, then go to the menu item: Source->Install. You will be prompted for a few responses most likely, and it will install gcc4.2. This should include libgfortran. You can now make the link I previously mentioned, and modelfree4 should work.

olifu02 01-13-2008 10:33 AM

The thing is, is i dont think my mac has gcc42. I see what you are talking about entering gcc and the last entry on the list looks just like the line of my last post, which is the gcc4.0. Sorry for being problematic. I have everything down except for having the gcc4.2. Once i get that im sure i can do all the rest.

olifu02 01-13-2008 10:57 AM

Nevermind..i updated using FinkCommander and i got gcc42. I am now installing it and will let you know how it goes. Thanks again

olifu02 01-13-2008 06:07 PM

so i installed gcc42 and it said for the final line

Reading Package Lists...
Building Dependency Tree...
Failed: can't create package gcc42_4.2.1-1000_darwin-i386.deb

not sure what that means but thought i wwouldt throw it out there.

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

so i tried modelfree4 and it said the same thing as before

Olson% modelfree4
dyld: Library not loaded: /usr/local/lib/libgfortran.2.dylib
Referenced from: /Users/Olson/Documents/Research/Modelfree/modelfree4_mac/Intel/modelfree4
Reason: image not found
Trace/BPT trap

should i delete sw and try to install fink and unpack gcc42 again?

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.