configure: error: *** -lm not found! **

configure: error: *** -lm not found! **

我正在尝试在静态模式下配置 agent2d 足球 2d 模拟的 librcsc,但出现此错误!

configure: error: *** -lm not found! **

我在命令行输入这个命令

make uninstall
make clean
make distclean
configure --disable-shared CXXFLAGS="-02 -march=i686"

这是我的配置日志:

configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/x86_64-suse-linux/bin/ld
checking if the linker (/usr/x86_64-suse-linux/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/x86_64-suse-linux/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... failed
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/x86_64-suse-linux/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking whether the g++ linker (/usr/x86_64-suse-linux/bin/ld) supports shared libraries... yes
libtool.m4: error: problem compiling CXX test program
checking for g++ option to produce PIC...  -DPIC
checking if g++ PIC flag  -DPIC works... no
checking if g++ static flag  works... no
checking if g++ supports -c -o file.o... no
checking if g++ supports -c -o file.o... (cached) no
checking whether the g++ linker (/usr/x86_64-suse-linux/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... unsupported
checking whether we are using the GNU C++ compiler... (cached) no
checking whether g++ accepts -g... (cached) yes
checking dependency style of g++... (cached) gcc3
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for cos in -lm... no
configure: error: *** -lm not found! ***

我也安装了 glibc-devel-static-32bit,但仍然出现此错误!

这是我的 conf.log:

configure:15391: checking for cos in -lm
configure:15416: g++ -o conftest -02 -m32 -march=i686   conftest.cpp -lm   >&5
g++: error: unrecognized command line option '-02'
configure:15416: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "librcsc"
| #define PACKAGE_TARNAME "librcsc"
| #define PACKAGE_VERSION "4.1.0"
| #define PACKAGE_STRING "librcsc 4.1.0"
| #define PACKAGE_BUGREPORT "akky@users.sourceforge.jp"
| #define PACKAGE_URL ""
| #define PACKAGE "librcsc"
| #define VERSION "4.1.0"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char cos ();
| int
| main ()
| {
| return cos ();
|   ;
|   return 0;
| }
configure:15425: result: no
configure:15430: error: *** -lm not found! ***

这是静态配置错误:

./configure CXXFLAGS="-O2 -march=i686 -static"

日志:

configure:2897: $? = 0
configure:2886: g++ -v >&5
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.8/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.8 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --enable-linker-build-id --enable-linux-futex --program-suffix=-4.8 --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version 4.8.5 (SUSE Linux) 
configure:2897: $? = 0
configure:2886: g++ -V >&5
g++: error: unrecognized command line option '-V'
g++: fatal error: no input files
compilation terminated.
configure:2897: $? = 1
configure:2886: g++ -qversion >&5
g++: error: unrecognized command line option '-qversion'
g++: fatal error: no input files
compilation terminated.
configure:2897: $? = 1
configure:2917: checking whether the C++ compiler works
configure:2939: g++ -O2 -march=i686 -static   conftest.cpp  >&5
conftest.cpp:1:0: error: CPU you selected does not support x86-64 instruction set
 /* confdefs.h */
 ^
configure:2943: $? = 1
configure:2981: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "agent2d"
| #define PACKAGE_TARNAME "agent2d"
| #define PACKAGE_VERSION "3.1.1"
| #define PACKAGE_STRING "agent2d 3.1.1"
| #define PACKAGE_BUGREPORT "akky@users.sourceforge.jp"
| #define PACKAGE_URL ""
| #define PACKAGE "agent2d"
| #define VERSION "3.1.1"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }

有人可以帮我吗?

您使用的 Linux 发行版是什么?正如您 运行 configure --disable-shared,您需要标准数学库的静态版本 libm.a。在 Debian/Ubuntu 上,此文件位于 libc6-dev 包中,在 Fedora 上,它可能位于 glibc-devel-static.

在 OpenSUSE 上你需要 glibc-devel-static。尝试 运行 yast -i glibc-devel-static,或使用基于 GUI 的 YaST 版本来安装软件包。请注意,您可能需要其他一些库的静态版本。

啊,抱歉,我没看到你也在使用 -march=i686。在这种情况下,您需要 glibc-devel-static-32bit