Home > Archive > Fortran > June 2005 > f77 how to link ar libraries to program
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
f77 how to link ar libraries to program
|
|
| clusardi2k@aol.com 2005-06-10, 4:00 pm |
| Hello,
When I attempt to link fortran archives in subdirectories to my
main, I get compilation errors. I tried to do it in 2 ways. Both
involved the "l" option.
If I use the l option I get the error:
/usr/clusardi/dir1/ar1.a No such file or directory.
If I do not use the l option I get the error:
/usr/clusardi/dir1/ar1.a is not used for resolving any symbol
How should I fix the makefile?
#basic makefile
all = a.out
LIBS = /usr/clusardi/dir1/ar1.a \
/usr/clusardi/dir2/ar2.a
OBJECTS = file1.o file2.o file3.o file4.o
a.out: $(OBJECTS)
f77 $(LIBS) $(OBJECTS)
| |
| Richard E Maine 2005-06-10, 4:00 pm |
| In article <1118421865.148071.232650@f14g2000cwb.googlegroups.com>,
clusardi2k@aol.com wrote:
> If I use the l option I get the error:
> /usr/clusardi/dir1/ar1.a No such file or directory.
The message seems straightforward enough. Is there such a file? I note
that it seems like an unusual path; your home directory is really in
/usr? That would be quite strange.
Also, when you don't know how to do something (as is naturally the case
when you are asking questions), you need to show exactly what you did.
Don't just describe it. In particular, don't just talk about "using the
l option"; show the exact commands instead. There are many ways to use
that option incorrectly; just saying that you "use it" doesn't give us
any hint.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
| |
| clusardi2k@aol.com 2005-06-10, 4:00 pm |
| I forgot the error!
clusardi2k@aol.com wrote:
>
> If I do not use the l option I get the warning:
> /usr/clusardi/dir1/ar1.a is not used for resolving any symbol
ERROR 33 : Unresolved text symbol first referenced by file1.o
Note: I tried to create the archives in two ways. I tried "ar r"
and "ar src" with the exact same results.
Thank you,
Christopher Lusardi
| |
| clusardi2k@aol.com 2005-06-10, 4:00 pm |
|
Richard E Maine wrote:
> Also, when you don't know how to do something (as is naturally the case
> when you are asking questions), you need to show exactly what you did.
> Don't just describe it. In particular, don't just talk about "using the
> l option"; show the exact commands instead. There are many ways to use
> that option incorrectly; just saying that you "use it" doesn't give us
> any hint.
The "l" option that I tried was:
#basic makefile
all = a.out
LIBS = l/usr/clusardi/dir1/ar1.a \
l/usr/clusardi/dir2/ar2.a
OBJECTS = file1.o file2.o file3.o file4.o
a.out: $(OBJECTS)
f77 $(LIBS) $(OBJECTS)
| |
| clusardi2k@aol.com 2005-06-10, 4:00 pm |
|
Richard E Maine wrote:
> In article <1118421865.148071.232650@f14g2000cwb.googlegroups.com>,
> clusardi2k@aol.com wrote:
>
>
> The message seems straightforward enough. Is there such a file? I note
> that it seems like an unusual path; your home directory is really in
> /usr? That would be quite strange.
>
The file exists because when I do "ls /usr/clusardi/dir1/ar1.a" it
tells me
it is readable.
Thank you,
Christopher Lusardi
| |
| clusardi2k@aol.com 2005-06-10, 4:00 pm |
| The specific error that I get with the "l" option is:
ld32:FATAL 9; I/O error
(-l/ar1.a): No such file or directory
f77 ERROR: /usr/lib32/cmplrs/ld32 returned non-zero status 32
*** Error code 2 (bu21)
Thanks,
Christopher Lusardi
P.S.: I got the same result when I used a blank between the -l and the
archive.
| |
| Erik Edelmann 2005-06-10, 4:00 pm |
| On 2005-06-10, clusardi2k@aol.com <clusardi2k@aol.com> wrote:
>
>
> Richard E Maine wrote:
>
> The "l" option that I tried was:
>
> #basic makefile
> all = a.out
> LIBS = l/usr/clusardi/dir1/ar1.a \
> l/usr/clusardi/dir2/ar2.a
> OBJECTS = file1.o file2.o file3.o file4.o
>
> a.out: $(OBJECTS)
> f77 $(LIBS) $(OBJECTS)
A few things to note:
1) The "-l" option needs a "-"
2) Library files are usually named libname.a rather than just
name.a
3) With the "-l" option you should give only the name of the library, not
the full path. E.g., if the the full path is /usr/clusardi/dir1/libar1.a,
you would use "-lar1" (i.e. leave out everything up to, and including, the
'lib' part of the name and the suffix ".a"). The directory of the libraries
can be specified with the "-L" option, in this case "-L/usr/clusardi/dir1/"
In conclusion; rename the library files /usr/clusardi/dir1/libar1.a and
/usr/clusardi/dir1/libar2.a, and change the definition of LIBS to
LIBS = -lar1 -lar2 -L/usr/clusardi/dir2/
Erik
| |
| clusardi2k@aol.com 2005-06-10, 4:00 pm |
| The specific error that I get with the "l" option is:
ld32:FATAL 9; I/O error
(-l/usr/clusardi/dir1/ar1.a): No such file or directory
f77 ERROR: /usr/lib32/cmplrs/ld32 returned non-zero status 32
*** Error code 2 (bu21)
Thanks,
Christopher Lusardi
P.S.: I got the same result when I used a blank between the -l and the
archive.
| |
| Richard E Maine 2005-06-10, 4:00 pm |
| In article <1118423566.339132.299150@g47g2000cwa.googlegroups.com>,
clusardi2k@aol.com wrote:
> The "l" option that I tried was:
>
> #basic makefile
> all = a.out
> LIBS = l/usr/clusardi/dir1/ar1.a \
> l/usr/clusardi/dir2/ar2.a
Well that's one of the many wrong ways to use it. This basically isn't
even close
1. It needs a dash before the l.
2. l does not take a path name. It takes a library name. Your libraries
don't have names in the form that it requires.
3. l interacts with L, which specifies the directories to search.
A correct usage of l would look more like
-L/usr/clusardi/dir1 -lar1
(this would require that your file be named libar1.a instead of just
ar1.a).
But I think you have other more basic problems. Trying to use -l is just
going to be an irrelevant distraction until you get those fixed. See the
other reply.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
| |
| clusardi2k@aol.com 2005-06-10, 4:00 pm |
| I'll try it.
Many thanks,
Christopher Lusardi
| |
| Richard E Maine 2005-06-10, 4:00 pm |
| In article <1118423421.468652.56660@g14g2000cwa.googlegroups.com>,
clusardi2k@aol.com wrote:
> Note: I tried to create the archives in two ways. I tried "ar r"
> and "ar src" with the exact same results.
Are those literally the *EXACT* command lines you used or are you trying
to describe what you did instead of showing it again? I'm going to sound
like a broken record, but it really is absolutely fundamental to getting
any kind of help. Give the raw data instead of your interpretation. For
example, the same comment about "ls showing the file as readable". That
is your interpretation of what ls showed.
This problem isn't unique to you, so don't feel picked on.
If "ar r" and "ar src" are the exact commands that you used, then the
problems aren't surprising. Those commands wouldn't do anything useful.
If those aren't the full, complete, and exact commands that you used,
then I can't tell what you actually did do. The error messages sound
like there is nothing in the library, but without seeing how you created
the library, there isn't much data to diagnose that.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
| |
| Richard E Maine 2005-06-10, 4:00 pm |
| In article <slrndajk9b.acb.eedelman@beam.acclab.Helsinki.FI>,
Erik Edelmann <eedelman@acclab.helsinki.fi> wrote:
> LIBS = -lar1 -lar2 -L/usr/clusardi/dir2/
I think you'll find that the -L needs to be before the -l in order to
work as desired. But I also think that this isn't the OP's most basic
problem anyway. See other posts.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
| |
| Erik Edelmann 2005-06-10, 8:57 pm |
| On 2005-06-10, Richard E Maine <nospam@see.signature> wrote:
> In article <slrndajk9b.acb.eedelman@beam.acclab.Helsinki.FI>,
> Erik Edelmann <eedelman@acclab.helsinki.fi> wrote:
>
>
> I think you'll find that the -L needs to be before the -l in order to
> work as desired.
Yes. I make this error almost every time I use the "-L" option. For some
reason I never learn :-/.
Erik
| |
| clusardi2k@aol.com 2005-06-10, 8:57 pm |
| Erik Edelmann wrote:
>
> A few things to note:
>
> 1) The "-l" option needs a "-"
>
> 2) Library files are usually named libname.a rather than just
> name.a
>
> 3) With the "-l" option you should give only the name of the library, not
> the full path. E.g., if the the full path is /usr/clusardi/dir1/libar1.a,
> you would use "-lar1" (i.e. leave out everything up to, and including, the
> 'lib' part of the name and the suffix ".a"). The directory of the libraries
> can be specified with the "-L" option, in this case "-L/usr/clusardi/dir1/"
>
> In conclusion; rename the library files /usr/clusardi/dir1/libar1.a and
> /usr/clusardi/dir1/libar2.a, and change the definition of LIBS to
>
> LIBS = -lar1 -lar2 -L/usr/clusardi/dir2/
>
I just tried everything you posted without success!
The error message really hasn't changed. It is
ld32 : FATAL 9 : I/O error (-lar1.a) : No such file or directory
f77 ERROR: /usr/lib32/cmplrs/ld32 returned non-zero status 32
*** Error code 2 (bu21)
For reasons of completeness, my makefile changes involved using two
-L's.
I.E. I am now using:
LIBS = -L/usr/clusardi/dir1/ -lar1 -L/usr/clusardi/dir2/ -lar2
In addition, I renamed the archives in their respective subdirectories
(/usr/clusardi/dir1/ and /usr/clusardi/dir2/) to be libar1.a and
libar2.a.
Thanks,
Christopher Lusardi
P.S.: I may post a more complete example Monday for you.
|
|
|
|
|