Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

MacOS X Catalina ifort linking problem

gragnani__eva
Beginner
3,437 Views

Hi,

my problem is that the linker fails with:
ld: library not found for -llibfparser.a

when I use:

ifort -L/usr/local/lib/ -I/usr/local/include/fparser-v1.1/ -llibfparser.a test.f90

if I compile specifying the complete path all is OK

ifort -I/usr/local/include/fparser-v1.1/ /usr/local/lib/libfparser.a test.f90

this gives me the correct executable file.

There are two modules that are correctly seen through the -I switch what seems to not work is the -L switch.

Thanks

(sorry for my English)

0 Kudos
1 Solution
mecej4
Honored Contributor III
3,437 Views

The convention used by the Linux linker ld for specifying library files is that the library file name is obtained by adding the prefix lib and adding the suffix .a to the ld argument prefixed by -l. Thus, -lmath is shorthand for libmath.a .

For more details of the -l command line option, see https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_mono/ld.html#SEC3 .

View solution in original post

0 Kudos
9 Replies
Ron_Green
Moderator
3,437 Views

try ordering -L and -l together like this:

ifort -I/usr/local/include/fparser-v1.1 -L/usr/local/lib -llibfparser.a test.f90

 

-L sets a library path and usually immediately preceeds the -l libraries.

 

Let me know if this works.

 

Ron

0 Kudos
mecej4
Honored Contributor III
3,438 Views

The convention used by the Linux linker ld for specifying library files is that the library file name is obtained by adding the prefix lib and adding the suffix .a to the ld argument prefixed by -l. Thus, -lmath is shorthand for libmath.a .

For more details of the -l command line option, see https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_mono/ld.html#SEC3 .

0 Kudos
gragnani__eva
Beginner
3,437 Views

Thanks Ron, but unfortunately nothing changes, I still have ld: library not found for -llibfparser.a.

 

0 Kudos
gragnani__eva
Beginner
3,437 Views

Thanks mecej4, it works!

ifort -L/usr/local/lib/ -I/usr/local/include/fparser-v1.1/ -lfparser test.f90

Eva

 

0 Kudos
gragnani__eva
Beginner
3,437 Views


Well, now from the terminal everything works but from xcode I continue to have the usual error.

In Targets --> Build Phases --> Link Binary With Libraries I have added libfparser.a and I also tried changing the name to fparser but the problem remains.

Obviously I set the directory for the .mod file and for the library:

Build Settings -->  Search Paths --> Header Search Paths --> /usr/local/include/function_parser/

Build Settings -->  Search Paths --> Library Search Paths --> /usr/local/lib/

Ideas?

Thanks Eva

 

0 Kudos
mecej4
Honored Contributor III
3,437 Views

I do not have a Macintosh and cannot help you with Xcode. I do not understand what you mean by "the usual error".

Do note that Xcode is deprecated with the current compiler release, and will be unsupported in a future release, according to https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/844666 .

0 Kudos
gragnani__eva
Beginner
3,437 Views

"the usual error" is: 

ld: library not found for -llibfparser.a

Another question, if Xcode is deprecated what IDE is available for MacOS? Eclipse, Visual Studio Code ...

Thanks Eva

0 Kudos
mecej4
Honored Contributor III
3,437 Views

gragnani, eva wrote:

"the usual error" is: 

ld: library not found for -llibfparser.a

In the place where you entered "libfparser.a" in Xcode, enter "fparser". 

gragnani, eva wrote:
Another question, if Xcode is deprecated what IDE is available for MacOS? Eclipse, Visual Studio Code ...

Whatever is available for MacOS. Someone else who is a Macintosh user will have to help you on that.

0 Kudos
gragnani__eva
Beginner
3,437 Views

Thanks for the reply macej4, but the problem is that xcode has a dialog box for loading a file (that is the library) and doesn't allow you to specify a name.

0 Kudos
Reply