/usr/bin/ld: crtbegin.o:没有这个文件或目录

8

我想安装llvm-clang,但在工作中没有root访问权限。我们的许多软件包已经过时,所以我正在本地在我的主目录下安装所有内容。

我已经安装了CMake和GCC,但现在在安装LLVM时遇到错误。

我的主目录结构如下:

~/gcc_build -> has the /bin directory which includes gcc, g++...etc (result of make install).

~/gcc-7.1.0 -> which has the main gcc build directory (where make was run)

~/llvm-4.0.0.src -> the main llvm directory 

~/llvm_make -> where I am trying to make llvm in (empty)

这是我的命令:

    [server-01:llvm_make]% ../cmake-3.8.2/bin/cmake ../llvm-4.0.0.src -DCMAKE_CXX_COMPILER=/home/sbay/gcc_build/bin/g++ -DCMAKE_C_COMPILER=/home/sbay/gcc_build/bin/gcc

但我遇到了这个错误:
[server-01:llvm_make]% ../cmake-3.8.2/bin/cmake ../llvm-4.0.0.src -DCMAKE_CXX_COMPILER=/home/sbay/gcc_build/bin/g++ -DCMAKE_C_COMPILER=/home/sbay/gcc_build/bin/gcc
-- The C compiler identification is GNU 7.1.0
-- The CXX compiler identification is GNU 7.1.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/sbay/bin/gcc
-- Check for working C compiler: /home/sbay/gcc_build/bin/gcc
-- Check for working C compiler: /whome/sbay/gcc_build/bin/gcc -- broken
CMake Error at /home/sbay/cmake-3.8.2/Modules/CMakeTestCCompiler.cmake:51 (message):
  The C compiler "/home/sbay/gcc_build/bin/gcc" is not able to
  compile a simple test program.

  It fails with the following output:

   Change Dir: /home/sbay/llvm_make/CMakeFiles/CMakeTmp



  Run Build Command:"/usr/bin/gmake" "cmTC_13e2f/fast"

  /usr/bin/gmake -f CMakeFiles/cmTC_13e2f.dir/build.make
  CMakeFiles/cmTC_13e2f.dir/build

  gmake[1]: Entering directory
  `/home/sbay/llvm_make/CMakeFiles/CMakeTmp'

  Building C object CMakeFiles/cmTC_13e2f.dir/testCCompiler.c.o

  /home/sbay/gcc_build/bin/gcc -o
  CMakeFiles/cmTC_13e2f.dir/testCCompiler.c.o -c
  /home/sbay/llvm_make/CMakeFiles/CMakeTmp/testCCompiler.c

  Linking C executable cmTC_13e2f

  /home/sbay/cmake-3.8.2/bin/cmake -E cmake_link_script
  CMakeFiles/cmTC_13e2f.dir/link.txt --verbose=1

  /home/sbay/gcc_build/bin/gcc
  CMakeFiles/cmTC_13e2f.dir/testCCompiler.c.o -o cmTC_13e2f

  /usr/bin/ld: crtbegin.o: No such file: No such file or directory

  collect2: error: ld returned 1 exit status

  gmake[1]: *** [cmTC_13e2f] Error 1

  gmake[1]: Leaving directory
  `/home/sbay/llvm_make/CMakeFiles/CMakeTmp'

  gmake: *** [cmTC_13e2f/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:47 (project)


-- Configuring incomplete, errors occurred!
See also "/home/sbay/llvm_make/CMakeFiles/CMakeOutput.log".
See also "/home/sbay/llvm_make/CMakeFiles/CMakeError.log".

我非常感激您提供的任何意见。

1个回答

3
您可以尝试添加--sysroot=选项,例如--sysroot=/home/lz/olimex/gcc-4.3.3/。

感谢您的评论,所以我添加了这个--sysroot=/home/sbay/gcc-7.1.0但是出现了这个错误:../cmake-3.8.2/bin/cmake ../llvm-4.0.0.src -DCMAKE_CXX_COMPILER=/home/sbay/gcc_build/bin/g++ -DCMAKE_C_COMPILER=/home/sbay/gcc_build/bin/gcc --sysroot=/home/sbay/gcc-7.1.0 CMake错误:源目录“/home/sbay/llvm_make/--sysroot=/home/sbay/gcc-7.1.0”不存在。 指定--help以获取用法信息,或按下CMake GUI上的帮助按钮。 - SFbay007
我的错,我添加了-DCMAKE_SYSROOT=/home/sbay/gcc-7.1.0,现在出现的错误是:/usr/bin/ld:该链接器未配置为使用sysroots。 - SFbay007
我猜你得找到其他的gcc版本或者启用sysroot来构建。 - LZ041
我现在已经下载了binutils并正在构建它。你认为我使用本地版本的ld会起作用吗?如何启用sysroot进行构建?我已经执行了./configure;make。这是错误的方法吗? - SFbay007
你认为我使用本地版本的ld会行吗?如果你的本地版本比较旧,很可能不起作用。你需要像--with-sysroot这样在./configure中添加一些内容(检查它有哪些选项)。 - LZ041

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接