The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   Library Not Loaded (http://hintsforums.macworld.com/showthread.php?t=125517)

bruhan 06-23-2011 03:26 PM

Library Not Loaded
 
Hi, I'm a newcomer and sm getting the following message when I try to execute a gfortran executable file:

dyld: Library not loaded: /usr/local/lib/libgfortran.3.dylib

I've tried a few things posted before but didn't apparently work. Can anyone give me a hand?

brettgrant99 06-23-2011 08:32 PM

Do you have gfortran installed on your system? Probably need a little more info.

Have you located the libgfortran.3.dylib? If so, you can set the environment variable DYLD_LIBRARY_PATH with the path to the library.

Brett

bruhan 06-23-2011 09:48 PM

Yes Brett, if I drag the file to the terminal it gives me a path, but if I type ls where it should be, I dont get anything. Should I still set the environment variable DYLD_LIBRARY_PATH with this path? How do I do that? Many tks.

hayne 06-24-2011 02:00 AM

Quote:

Originally Posted by bruhan (Post 627550)
Should I still set the environment variable DYLD_LIBRARY_PATH with this path? How do I do that?

See the env vars section of this Unix FAQ

brettgrant99 06-24-2011 02:04 AM

I don't understand what you are doing. What file are you dragging to the terminal? The library or the executable?

What shell are you using in the Terminal?

What version of gcc are you using? Is the executable that you have something that you compiled?

Which OS version do you have? Is it an intel or ppc?

On the version that I have, the actual library is in /usr/local/gcc-4.3.4/lib

Using csh, I would do this:

setenv DYLD_LIBRARY_PATH /usr/local/gcc-4.3.4/lib

and it should find it. However, if you didn't compile the program, run otool -L to see where executable thinks that it should look for the library.

Maybe run
Code:

otool -L executable
and post the output.

Brett

bruhan 06-24-2011 09:27 AM

Dear Brett, I typed the library file on the finder and then dragged it to the terminal. As I listed the files in the directory, the lib file did not show.

I don't know which shell I am using. How can I find this out?

The version is gcc 4.0.1. Yes, the executable is a compiled file.

The OS version is OS X v 10.6.7 Intel core 2 Duo.

The library seems to be at /usr/local/lib/i386 another identical file is at /usr/local/lib

I understand I have to redirect where it looks for the library file. How do I use csh, though? Sorry, quite a few questions...

trevor 06-24-2011 11:44 AM

Quote:

I don't know which shell I am using. How can I find this out?
Try
echo $SHELL

You will most likely see:

Code:

% echo $SHELL
/bin/bash

%

...which means you are using the bash shell.

Trevor

bruhan 06-24-2011 02:18 PM

That what I get when I Type echo $SHELL: /bin/bash

bruhan 06-24-2011 02:25 PM

Thanks hayne.

brettgrant99 06-24-2011 02:49 PM

What is the response from the otool command?

What is the response from gcc -v?

Thanks,
Brett

bruhan 06-24-2011 04:53 PM

Sorry Brett.

This is what I get from otool:

/usr/local/lib/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)
/usr/local/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/lib/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)

bruhan 06-24-2011 04:56 PM

gcc -v gave me:


Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5646~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5646)

Tks

brettgrant99 06-24-2011 06:03 PM

I'm not at home, so I can't check right away (no macs at work anymore), but I thought that otool -L would give some form of output like this (which is off of a linux box)

Code:

libg2c.so.0 => /usr/lib64/libg2c.so.0 (0x0000002a9557f000)
        libm.so.6 => /lib64/tls/libm.so.6 (0x0000003460a00000)
        libgnat-3.4.so.1 => /usr/lib64/libgnat-3.4.so.1 (0x0000002a956a1000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003463200000)
        libc.so.6 => /lib64/tls/libc.so.6 (0x0000003460700000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003460300000)

If it can't find the library, it puts a "not found" after the =>

I can check it out this evening. Your gcc wasn't compiled with gfortran, where did you get the fortan libraries from? Did you install the libraries without the compiler. If you have the compiler, what does it say when you do:
Code:

gfortran -v
That could be causing some of your issues. Do you know which vendor and version the executable was created with?

Quote:

Dear Brett, I typed the library file on the finder and then dragged it to the terminal. As I listed the files in the directory, the lib file did not show.
I just noticed this. This would indicate to me that you do not have the fortran libraires installed. Apple doesn't really support fortran.

What is the output from the terminal of
Code:

ls -lh /usr/local/lib/libg*
?

I think that in finder, you can also hit apple-g and type in /usr/local/lib to view it in the finder.

Brett

bruhan 06-24-2011 06:35 PM

Dear Brett,

gfortran -v gave me:

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/Users/brunohannud/Downloads/usr/local/bin/../libexec/gcc/x86_64-apple-darwin10.7.0/4.6.0/lto-wrapper
Target: x86_64-apple-darwin10.7.0
Configured with: ../gcc-4.6.0/configure --enable-languages=fortran
Thread model: posix
gcc version 4.6.0 (GCC)

I created the executable by typing gfortran -o executablefile sourcefile.for
(is this what you're asking?)

After the ls command I get:

lrwxr-xr-x 1 root wheel 79B 23 Jun 15:48 /usr/local/lib/libgfortran.2.dylib -> /Library/Frameworks/R.framework/Versions/2.10/Resources/lib/libgfortran.2.dylib

I think I created this file yesterday while attempting to follow the recommendation on the web to another similar problem.

brettgrant99 06-24-2011 08:24 PM

What file did you create yesterday?

Can you compile a hello world program in fortran? I also have a little bit of concern that you are using an older version of gcc than of gfortran.

Brett

bruhan 06-24-2011 09:33 PM

Brett, I downloaded gfortran from http://www.webmo.net/support/fortran_osx.html

I followed what "horn" suggested here to create the lib file yesterday;

http://openmx.psyc.virginia.edu/thread/316

Here's what I get for my HelloWorld:

/Users/brunohannud/Documents/Doutorado/ExecutaveisTurns/HELLOWORLD ; exit;
Neo-3:~ brunohannud$ /Users/brunohannud/Documents/Doutorado/ExecutaveisTurns/HELLOWORLD ; exit;
dyld: Library not loaded: /usr/local/lib/libgfortran.3.dylib
Referenced from: /Users/brunohannud/Documents/Doutorado/ExecutaveisTurns/HELLOWORLD
Reason: image not found
Trace/BPT trap
logout

hayne 06-24-2011 10:25 PM

Quote:

Originally Posted by bruhan (Post 627703)
I followed what "horn" suggested here to create the lib file yesterday;

http://openmx.psyc.virginia.edu/thread/316

That (older) post by 'horn' that you referred to showed commands that used /usr/local/lib/libgfortran.2.dylib
but your program is apparently looking for /usr/local/lib/libgfortran.3.dylib

brettgrant99 06-25-2011 02:54 AM

Please don't take this as a criticism. I think that you need to step back for a moment and maybe explain what you are trying to do, provide some EXACT steps on what you have done and results. Many of your answers seem contradictory and partial to me. I apologize that I don't get it, perhaps we just don't think alike, but it really isn't clear to me. This will probably be a long post. I learned tcsh first, so all of my commands are relative to tcsh. If you use bash, I know a few basics, but not much. You can get a tcsh by typing tcsh at the command line if your default shell is bash or sh.

I am certainly not an expert at compilers or fortran. About 5 years ago I was given some tasks at work that led me to figure out how to compile and run some fortran programs using g77 on 10.4. At some point I needed to upgrade to gfortran and then to gfortran on Leopard. I no longer need to do this work, so I have not tried development on 10.6. Much of what I have to say are observations that I have noticed, and may or may not be best practices. All of my experience was with command line applications, so I don't really know about Cocoa or the other APIs.

My first belief is that the compiler should be stand alone, that is, all of the compilers and components, such as libraries, include files, etc, should be contained in a single directory. This will allow you to have different versions of gcc. These should be installed in /usr/local. I personally prefer to define which version is used in my path, but you can put softlinks in /usr/local/bin.

Once you have your compiler in /usr/local, make sure the compiler that you want to use is at the top of your path. You can test this with the command
Code:

where gcc
Now unfortunately, it seems like you have kind of grab bits and bobs from all over the internet and some of that information may be contradictory. If possible, I would restore you machine back to the state it was in before you started any of this. Unfortunately, I don't really know what your end goal is, so there are some guesses in here. This is what I would do.
  1. Install Xcode
  2. Install fortran
  3. Test fortran
  4. install program that wants fortran (R maybe)
  5. test program that uses fortran
  6. go get a good beer

Now it seems like #2 may or may not be done correctly, it is clear that #3 is not working. So let us work on getting fortran working.

Here is a very simple Hello World program, name it hello.f
Code:

      program main

      write(0,*) 'Hello World'

      end program

Now compile it and run it
Code:

~/work/>gfortran hello.f
~/work/>a.out
 Hello World
~/work/>

(please notice that I copy and pasted the results from the terminal in [CODE] tags. This makes it easier to see what is being done.)

Here is an example of an C executable with a missing library.
Code:

~/libTest/src/>a.out
dyld: Library not loaded: libmean.dylib
  Referenced from: /Users/bgrant/libTest/src/a.out
  Reason: image not found
Trace/BPT trap

Now it isn't clear what fortran compiler you have. The page that you reference has at least 6 different links, and some of those pages have links to even more version. From the descriptions, I would pick the GCC Wiki version.

Where did the compiler install? In my case it installed the directory gfortran in /usr/local.

Code:

total 0
drwxrwxr-x  9 root  wheel  306B Apr 18  2007 ada-4.3/
drwxr-xr-x  3 root  wheel  102B Nov  1  2008 man/
drwxr-xr-x  3 root  wheel  102B Jul 31  2009 etc/
drwxr-xr-x  10 root  wheel  340B Oct 24  2009 gcc-4.3.4/
drwxr-xr-x  7 root  admin  238B May  6  2010 gfortran/
drwxr-xr-x  22 root  wheel  748B Jul 22  2010 lib/
drwxr-xr-x  5 root  wheel  170B Jul 22  2010 include/
drwxr-xr-x  9 root  wheel  306B Nov 10  2010 share/
drwxr-xr-x  31 root  wheel  1.0K Jun 24 23:24 bin/
/usr/local/>ls -lhG gfortran
total 0
drwxr-xr-x  7 root  admin  238B May  6  2010 bin/
drwxr-xr-x  3 root  admin  102B May  6  2010 include/
drwxr-xr-x  33 root  admin  1.1K Jun 24 23:24 lib/
drwxr-xr-x  3 root  admin  102B May  6  2010 libexec/
drwxr-xr-x  3 root  admin  102B May  6  2010 share/
/usr/local/>ls -lhG gfortran/bin
total 2704
-rwxr-xr-x  1 root  admin  317K May  6  2010 cpp*
-rwxrwxr-x  1 root  admin  317K May  6  2010 g++*
-rwxr-xr-x  1 root  admin  313K May  6  2010 gcc*
-rwxr-xr-x  1 root  admin    69K May  6  2010 gcov*
-rwxr-xr-x  1 root  admin  321K May  6  2010 gfortran*
/usr/local/>

Here are some directory listings for my system. Notice that the commands follow the prompt
Code:

/usr/local/>
Notice that there is a gcc in the /usr/local/gfortran/bin. This is the gcc you should be using, not the one in /usr/bin.

I don't believe that this is needed, but just for completeness
Code:

/usr/local/>find /usr/local/gfortran -name 'libgfort*'
/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/i386/libgfortranbegin.a
/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/i386/libgfortranbegin.la
/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/libgfortranbegin.a
/usr/local/gfortran/lib/gcc/x86_64-apple-darwin10.3.0/4.5.1/libgfortranbegin.la
/usr/local/gfortran/lib/i386/libgfortran.3.dylib
/usr/local/gfortran/lib/i386/libgfortran.a
/usr/local/gfortran/lib/i386/libgfortran.dylib
/usr/local/gfortran/lib/i386/libgfortran.la
/usr/local/gfortran/lib/libgfortran.3.dylib
/usr/local/gfortran/lib/libgfortran.a
/usr/local/gfortran/lib/libgfortran.dylib
/usr/local/gfortran/lib/libgfortran.la
/usr/local/>

This shows where libgfortran.3.dylib is.

Perhaps you should try and duplicate this post and let us know how it goes.

On a side note. I haven't really used dynamic libraries too much. It turns out otool -L reports the library paths that were used at compile time, but does not give any information about the status of the actual library.
Code:

otool -l library file
has some info buried in it.

Let us know how it works out.
Brett

bruhan 06-25-2011 07:37 AM

Thanks Brett. I will work on this during today. I just realized (!!!) that the programs I want to run are written in F77L Fortran v5.01.

I'll try to start from the beggining and install a version of this compiler.

I'll follow your instructions and let you know how it goes.

bruhan 06-25-2011 07:39 AM

Should I unistall everything? How do I go on doing that? Tks

bruhan 06-25-2011 07:46 AM

Just discovered gfortran is compatible with the f77.

bruhan 06-25-2011 03:16 PM

X Code reinstalled...

bruhan 06-25-2011 03:31 PM

Created a /usr/local/bin path: "export PATH=$PATH:/usr/local/bin

bruhan 06-25-2011 04:40 PM

locate gfortran gave me: /usr/local/lib/libgfortran.2.dylib

bruhan 06-25-2011 04:44 PM

version gfortran 4.2.3 from here: http://r.research.att.com/tools/

bruhan 06-25-2011 04:52 PM

Tried to run HelloWorld and this is what I got.


Neo-3:~ brunohannud$ /Users/brunohannud/Documents/Doutorado/ExecutaveisTurns/HELLOWORLD /Users/brunohannud/Documents/Doutorado/ExecutaveisTurns/HELLOWORLD.FOR
dyld: Library not loaded: /usr/local/lib/libgfortran.3.dylib
Referenced from: /Users/brunohannud/Documents/Doutorado/ExecutaveisTurns/HELLOWORLD
Reason: image not found
Trace/BPT trap

bruhan 06-25-2011 04:53 PM

Neo-3:~ brunohannud$ cd /usr/local/lib
Neo-3:lib brunohannud$ ls
ImageMagick-6.6.1 libgcc_s_ppc64.1.dylib libgfortran.dylib
gcc libgcc_s_x86_64.1.dylib libgfortran.la
libgcc_s.1.dylib libgfortran.2.0.0.dylib libpolar-3.1.4.dylib
libgcc_s.10.4.dylib libgfortran.2.dylib ppc64
libgcc_s.10.5.dylib libgfortran.a x86_64

bruhan 06-25-2011 04:58 PM

YES!! HEllo World Working!!!!!!!

brettgrant99 06-25-2011 05:23 PM

Good. Do you need more help, or can you take it from here?

Brett

bruhan 06-25-2011 05:28 PM

Brett, Thank you immensely. Straight logic... magic from your side. I'll try to take it from here.


All times are GMT -5. The time now is 10:38 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.