"/usr/bin/ld: cannot find library"

TTT picture TTT · May 8, 2012 · Viewed 97.2k times · Source

This is my first time trying to compile FORTRAN code using a makefile. The OS is Ubuntu 12.04 LTS 64 bit. I encountered the following errors:

gfortran  -o przm3123.exe canopy.o chem.o cnfuns.o cropdate.o datemod.o debug.o debug_cn.o f2kcli.o floatcmp.o furrow.o general.o i_errchk.o infnan.o inivar.o ioluns.o iosubs.o lambertw.o m_readvars.o utils.o wind.o fcscnc.o przm3.o rsexec.o rsinp1.o rsinp2.o rsinp3.o rsmcar.o rsmisc.o rsprz1.o rsprz2.o rsprz3.o rsprzn.o rsutil.o rsvado.o -L ../libanne4.0/lib -lwdm -ladwdm -lutil
/usr/bin/ld: cannot find -lwdm
/usr/bin/ld: cannot find -ladwdm
collect2: ld returned 1 exit status
make: *** [przm3123.exe] Error 1

The key element in the makefile is:

przm2_LIBS = -L ../libanne4.0/lib -lwdm -ladwdm -lutil

Is there anything I can do to fix this error? Should I try other compilers?

Answer

alk picture alk · May 8, 2012

As ../libanne4.0/lib is a relative path, you might try changing it into an absolute one.

Also you could check whether the linker process has the rights to access and read the libs.


Update: To have the linker find a library specified using the option -l<name> the name of the libray shall be lib<name>.[a|so] and the parameter to -L should point the path were the library is located.

-L needs to preceed it's -l option(s).

One could specify -l and/or -L multiple times.