- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've searched the forum for this issue but no luck.
This is my first time trying to link user libs into my source code on linux.
I am NOT using -static or -fast when I compile.
libA.a and libB.a are both archive files I created.
My link statement is,
-L. -l:libA.a -l:libB.a
When I try to compile my program I get the following.
ifort -L. -llibA.a -llibB.a -o prog.exe
ld: cannot find -llibA.a
Yes, the lib files are located in the same directory as the makefile and source code.
Any suggestions? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On Linux, the ld utility takes the argument to the "-l" switch and prepends the letters "lib" and postfixes either .a or .so until it finds a match.
So, assuming your libraries are literally named "libA.a" and "libB.a", please try this command:
ifort -L. -lA -lB -o prog.exe
--Lorri
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Linux-speak is a bit different. You want:
-L. -lA -lB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The syntax is of the form
ifort *.f -lA -lB
If you mean to compile and link all the .f files in the current directory. It won't work without source and/or object files prior to the -l directives. As Lorri reminded us, -l implies lib and .a or .so. I don't know what Makefile fortmat you are using; what you show doesn't look standard.
The form required by the standard linux utility ld, has overwhelming documentation.
https://www.gnu.org/software/binutils/
-L./ is OK if the .a files are in the current working directory, but probably redundant.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On Linux, the ld utility takes the argument to the "-l" switch and prepends the letters "lib" and postfixes either .a or .so until it finds a match.
So, assuming your libraries are literally named "libA.a" and "libB.a", please try this command:
ifort -L. -lA -lB -o prog.exe
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the help. I'm not very knowledgeable on compiling and linking with various systems so sometimes trying to interpret overwhelming documentation can be difficult.
Once I understood the prepend lib and postpend .a characteristics, I got it to work. Lorri's response was the easiest for me to understand. Thanks, all.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page