Linking CXX executable ../../bin/nebula-storaged c++: error: unrecognized command line option ‘-fuse-ld=’; did you mean ‘-fuse-ld=bfd’?

[ 62%] Linking CXX executable …/…/bin/nebula-storaged
c++: error: unrecognized command line option ‘-fuse-ld=’; did you mean ‘-fuse-ld=bfd’?
src/daemons/CMakeFiles/nebula-storaged.dir/build.make:572: recipe for target ‘bin/nebula-storaged’ failed
make[2]: *** [bin/nebula-storaged] Error 1
CMakeFiles/Makefile2:7519: recipe for target ‘src/daemons/CMakeFiles/nebula-storaged.dir/all’ failed
make[1]: *** [src/daemons/CMakeFiles/nebula-storaged.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…

[ 94%] Built target meta_service_handler
Makefile:151: recipe for target ‘all’ failed
make: *** [all] Error 2

编译环境的链接器可能探测不太对,试试重新cmake一下?或者尝试增加-DNEBULA_USE_LINKER=bfd这样?

1 个赞

cmake -DCMAKE_INSTALL_PREFIX=/opt/nebula -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release … -DNEBULA_USE_LINKER=bfd

[ 72%] Linking CXX executable …/…/bin/nebula-storaged
collect2: fatal error: cannot find ‘ld’
compilation terminated.
src/daemons/CMakeFiles/nebula-storaged.dir/build.make:572: recipe for target ‘bin/nebula-storaged’ failed
make[2]: *** [bin/nebula-storaged] Error 1
CMakeFiles/Makefile2:7519: recipe for target ‘src/daemons/CMakeFiles/nebula-storaged.dir/all’ failed
make[1]: *** [src/daemons/CMakeFiles/nebula-storaged.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…

看下gcc版本呢?这个看上去是链接器找不到或者配置不正确,一般直接编译就可以了,我先看下有没有地方能系统指定这个哈。

gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc -v的输出信息贴一下?

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/gcc/bin/…/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: …/configure --enable-languages=c,c++ --prefix=/opt/gcc920
Thread model: posix
gcc version 9.2.0 (GCC)

我大概看了一个针对ld找不到的问题,基本是在你的gcc环境中,创建一个名为ld的软连接,指向你具体的链接程序。
NEBULA_USE_LINKER=bfd 这个后面跟应该跟的是你链接器的后缀,比如ld.bfd,你可以在你gcc的目录里查找一下ld开头的程序(如果which ld能找到的话,可能还是cmake这边有啥问题)
这样虽然可能能解决问题,但我不知道具体是什么导致不能直接开始编译的。

which: no ld.bfd in (/opt/gcc/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/bin:/sbin:/usr/bin:/usr/sbin)

如果不加-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
– The C compiler identification is GNU 9.2.0
– The CXX compiler identification is GNU 9.2.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – broken
CMake Error at /opt/cmake/share/cmake-3.14/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
“/usr/bin/cc”
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /opt/nebula-2.6.2/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake cmTC_e52be/fast
/usr/bin/gmake -f CMakeFiles/cmTC_e52be.dir/build.make CMakeFiles/cmTC_e52be.dir/build
gmake[1]: Entering directory ‘/opt/nebula-2.6.2/build/CMakeFiles/CMakeTmp’
Building C object CMakeFiles/cmTC_e52be.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTC_e52be.dir/testCCompiler.c.o -c /opt/nebula-2.6.2/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_e52be
/opt/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e52be.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_e52be.dir/testCCompiler.c.o -o cmTC_e52be
collect2: fatal error: cannot find ‘ld’
compilation terminated.
CMakeFiles/cmTC_e52be.dir/build.make:86: recipe for target ‘cmTC_e52be’ failed
gmake[1]: *** [cmTC_e52be] Error 1
gmake[1]: Leaving directory ‘/opt/nebula-2.6.2/build/CMakeFiles/CMakeTmp’
Makefile:121: recipe for target ‘cmTC_e52be/fast’ failed
gmake: *** [cmTC_e52be/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:24 (project)

你的编译环境看上去有问题,起码ld是找不到的,可能是path有问题,也可能是linker的命名方式或者软连接问题,你gcc编一个简单的helloworld来试试呢?

也可以试试我们已经提前构建好的环境来试用一下。

此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。