检查g ++是否可以链接程序

时间:2017-02-20 15:23:17

标签: c++ g++ glibc

我在尝试构建glibc时在日志中收到以下错误:

configure:3180: checking whether g++ can link programs
configure:3203: g++ -o conftest -g -O2   conftest.cpp  >&5
configure:3203: $? = 0
configure:3226: g++ -o conftest -g -O2   -static conftest.cpp  >&5
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lm
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
configure:3226: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU C Library"
| #define PACKAGE_TARNAME "glibc"
| #define PACKAGE_VERSION "(see version.h)"
| #define PACKAGE_STRING "GNU C Library (see version.h)"
| #define PACKAGE_BUGREPORT "http://sourceware.org/bugzilla/"
| #define PACKAGE_URL "http://www.gnu.org/software/glibc/"
| #define PKGVERSION "(GNU libc) "
| #define REPORT_BUGS_TO "<http://www.gnu.org/software/libc/bugs.html>"
| /* end confdefs.h.  */
|
| #include <iostream>
|
| int
| main()
| {
|   std::cout << "Hello, world!";
|   return 0;
| }
|
configure:3241: result: no
configure:3248: error: you must configure in a separate build directory

任何想法如何解决?

如何重现它:

here下载glibc并尝试制作./configure

1 个答案:

答案 0 :(得分:0)

我认为错误本身是否是一个很好的提示?它说您应该在构建目录中进行配置,因此在顶部源目录中创建一个名为build的目录并cd到它然后运行../configure。