libtool can't find the la when linking with option -L

折月煮酒 提交于 2021-02-11 18:16:09

问题


I met the problem when compiling the source code of mpc which will depend on gmp. The command to compile mpc is as below.

./configure --with-mpfr=/home/wy/tmp/mpfr-4.0.2/ins --with-gmp=/home/wy/tmp/gmp-6.2.0/ins --prefix=/home/wy/tmp/mpc-1.1.0/ins

The gmp has been installed into /home/user/tmp/gmp-6.2.0/ins successfully.

The error when compiling mpc with libtool is as below.

/bin/bash ../libtool  --tag=CC   --mode=link gcc -std=gnu99  -O2 -pedantic -fomit-frame-pointer -m64 -mtune=corei7 -march=corei7  -version-info 4:0:1 -L/home/wy/tmp/gmp-6.2.0/ins/lib -L/home/wy/tmp/mpfr-4.0.2/ins/lib  -o libmpc.la -rpath /home/wy/tmp/mpc-1.1.0/ins/lib abs.lo acos.lo acosh.lo add.lo add_fr.lo add_si.lo add_ui.lo arg.lo asin.lo asinh.lo atan.lo atanh.lo clear.lo cmp.lo cmp_abs.lo cmp_si_si.lo conj.lo cos.lo cosh.lo div_2si.lo div_2ui.lo div.lo div_fr.lo div_ui.lo exp.lo fma.lo fr_div.lo fr_sub.lo get_prec2.lo get_prec.lo get_version.lo get_x.lo imag.lo init2.lo init3.lo inp_str.lo log.lo log10.lo mem.lo mul_2si.lo mul_2ui.lo mul.lo mul_fr.lo mul_i.lo mul_si.lo mul_ui.lo neg.lo norm.lo out_str.lo pow.lo pow_fr.lo pow_ld.lo pow_d.lo pow_si.lo pow_ui.lo pow_z.lo proj.lo real.lo rootofunity.lo urandom.lo set.lo set_prec.lo set_str.lo set_x.lo set_x_x.lo sin.lo sin_cos.lo sinh.lo sqr.lo sqrt.lo strtoc.lo sub.lo sub_fr.lo sub_ui.lo swap.lo tan.lo tanh.lo uceil_log2.lo ui_div.lo ui_ui_sub.lo  -lmpfr -lmpfr -lgmp -lm 
/bin/grep: /usr/local/lib/libgmp.la: No such file or directory
/bin/sed: can't read /usr/local/lib/libgmp.la: No such file or directory
libtool:   error: '/usr/local/lib/libgmp.la' is not a valid libtool archive
Makefile:432: recipe for target 'libmpc.la' failed
make[2]: *** [libmpc.la] Error 1
make[2]: Leaving directory '/home/wy/tmp/mpc-1.1.0/src'
Makefile:465: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/wy/tmp/mpc-1.1.0'
Makefile:375: recipe for target 'all' failed
make: *** [all] Error 2

From the error message, we can see that the lib path has been indicated as -L/home/wy/tmp/gmp-6.2.0/ins/lib. But libtool still can't find the lib.


回答1:


This is going to be hard to answer easily, but it seems like you have some other .la file that references it, and causes it to fail this way. Paths within .la files are always absolute. See this old blog post of mine for details.

My best guess for your particular case, is that you have an old copy of mpfr installed in /usr/local — and that is taking precedence over the one you want to use.




回答2:


The problem appears to be in the MPFR configure scripts or makefile, not in MPC!

As you can see above, it's not looking for libgmp.la in the place you specified on the command-line, but in the default installation location. The reason for this is that the location of libgmp.la is specified incorrectly in libmpfr.la! It's not MPC's fault...

I was able to work around the problem by editing libmpfr.la, which you can find where you specified the MPFR libraries to go, and change the location to libgmp.la from /usr/lib/libgmp.la to the actual location where you targeted the GMP libraries.

The line in libgmp.la should look like this:

# Libraries that this one depends upon.
dependency_libs=' -L/your/mpfr/lib/target /your/gmp/lib/target/libgmp.la

Where "/your/mpfr/lib/target" should be where you told MPFR to put its library files, and "/your/gmp/lib/target" needs to be changed to where you told GMP to put its library files.



来源:https://stackoverflow.com/questions/62485677/libtool-cant-find-the-la-when-linking-with-option-l

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!