From: Uno on
Craig Powers wrote:

[x-posting again as in original post]
> Uno wrote:
>> $ gfortran -llibposix90.a blev1.f90 -o out
>> /usr/bin/ld: cannot find -llibposix90.a
>> collect2: ld returned 1 exit status
>
> A standard feature of Unix-derived operating systems is that when
> specifying a library to a compiler via the '-l' switch, the leading
> 'lib' is omitted (as is the extension). Thus, the correct form of this
> command line would be,
> gfortran -lposix90 blev1.f90 -o out

$ gfortran -o out blev1.f90 libposix90.a

works.

$ gfortran -lposix90 blev1.f90 -o out
/usr/bin/ld: cannot find -lposix90
collect2: ld returned 1 exit status
$ ls *
blev1.f90 ChangeLog f90_unix_dirent.mod libposix90.a Makefile~ text1
blev1.f90~ COPYING INSTALL Makefile README

....
lib:
libposix90.a text1.txt

It doesn't want to find it. ??

>
> (assuming that libposix90.a is in the default library search path for
> gfortran... if it is and it's not being found, you may wish to try
> running ldconfig, otherwise you may wish to use the -L switch to
> instruct gfortran to search in that location in addition to the default
> search path.)

Since the original post, the kinks have been worked out on the fortran
side of it, and I'm left with questions having to do with the platform,
hence the x-post.

It looks to me like ldconfig is looking only one place for libraries:
$ ldconfig -p >text4

739 libs found in cache `/etc/ld.so.cache'
libzephyr.so.3 (libc6) => /usr/lib/libzephyr.so.3
libz.so.1 (libc6) => /lib/libz.so.1
libx264.so.65 (libc6) => /usr/lib/libx264.so.65
libx86.so.1 (libc6) => /lib/libx86.so.1
libxvidcore.so.4 (libc6) => /usr/lib/libxvidcore.so.4

I've read the man pages for ld and ldconfig and have the headache to
prove it. What is ldconfig supposed to do?
--
Uno
From: steve on
On Apr 10, 3:41 pm, Uno <merrilljen...(a)q.com> wrote:
> Craig Powers wrote:
>
> [x-posting again as in original post]
>
> > Uno wrote:
> >> $ gfortran  -llibposix90.a  blev1.f90  -o out
> >> /usr/bin/ld: cannot find -llibposix90.a
> >> collect2: ld returned 1 exit status
>
> > A standard feature of Unix-derived operating systems is that when
> > specifying a library to a compiler via the '-l' switch, the leading
> > 'lib' is omitted (as is the extension).  Thus, the correct form of this
> > command line would be,
> > gfortran -lposix90 blev1.f90 -o out
>
> $ gfortran -o out blev1.f90 libposix90.a
>
> works.
>
> $ gfortran -lposix90 blev1.f90 -o out
> /usr/bin/ld: cannot find -lposix90
> collect2: ld returned 1 exit status
> $ ls *
> blev1.f90   ChangeLog  f90_unix_dirent.mod  libposix90.a  Makefile~  text1
> blev1.f90~  COPYING    INSTALL              Makefile      README
>
> ...
> lib:
> libposix90.a  text1.txt
>
> It doesn't want to find it. ??
>
>

You did not tell the compiler where to look for
the library. RTFM. See the -L option.

Try adding -L. to the command line.

--
steve
From: Alan Curry on
In article <82cd4vFiscU1(a)mid.individual.net>, Uno <merrilljensen(a)q.com> wrote:
|Craig Powers wrote:
|
|I've read the man pages for ld and ldconfig and have the headache to
|prove it. What is ldconfig supposed to do?

fortran is Greek to me, but I can provide a simple answer to that one:
in its most common usage, ldconfig notifies the system that a new library has
been installed in /usr/lib so that the dynamic linker will be able to find it
when it's needed.

It could also be used when other changes are made to the system's shared
libraries (one got a removed, or the directory list in /etc/ld.so.conf has
been modified).

It has no effect at all on the linking of lib*.a libraries, or anything else
that happens at build time. That's what -L is for.

--
Alan Curry
From: Uno on
steve wrote:

> You did not tell the compiler where to look for
> the library. RTFM. See the -L option.
>
> Try adding -L. to the command line.

Thx, steve. It's not the easiest thing to find, but it is there.

This is an instance where this excerpt from gfortran.pdf is relevant:

The gfortran command supports all the options supported by the gcc
command. Only
options specific to GNU Fortran are documented here.
See Section �GCC Command Options� in Using the GNU Compiler
Collection (GCC),
for information on the non-Fortran-specific aspects of the gcc command
(and, therefore,
the gfortran command).
All GCC and GNU Fortran options are accepted both by gfortran and
by gcc (as well
as any other drivers built at the same time, such as g++), since adding
GNU Fortran to the
GCC distribution enables acceptance of GNU Fortran options by all of the
relevant drivers.
In some cases, options have positive and negative forms; the
negative form of �-ffoo�
would be �-fno-foo�. This manual documents only one of these two forms,
whichever one
is not the default.

! end excerpt

Then in gcc.pdf is:

Add directory dir to the list of directories to be searched for �-l�.
-Ldir

$ gfortran -o out2 blev1.f90 -L/lib/ -lposix90
/usr/bin/ld: cannot find -lposix90
collect2: ld returned 1 exit status
$ gfortran -o out2 blev1.f90 -L/lib/ libposix90.a
$ ./out2
apue.2e
...
caller2.f90~
$

So I appear not to have the extension for -l that lops off the lib and
the filetype.

Question: Since I've started into unix, I tend to compile with
-D_GNU_SOURCE -Wall and -Wextra. Do these options make sense when
compiling with gfortran?
--
uno

From: steve on
On Apr 10, 7:50 pm, Uno <merrilljen...(a)q.com> wrote:
> steve wrote:

> $ gfortran -o out2 blev1.f90 -L/lib/ -lposix90
> /usr/bin/ld: cannot find -lposix90
> collect2: ld returned 1 exit status

> $ gfortran -o out2 blev1.f90 -L/lib/ libposix90.a
> $ ./out2
>   apue.2e
>    ...
>   caller2.f90~
> $
>
> So I appear not to have the extension for -l that lops off the lib and
> the filetype.

Please read what I wrote. Add '-L.' to the command line.
I did not write '-L/lib/'. How in the heck did you arrive
at '-L/lib/'? Is libposix.a located in a directory named
'/lib/?

--
steve



First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Do Loops
Next: Usage of iso_c_binding