/usr/bin/ld: cannot find -lc++

女生的网名这么多〃 提交于 2021-02-11 14:30:43

问题


I am following a tutorial on building an audio classifier here and when reach to the step where I run the sh build.sh I get the cannot find -lc++ error.

Kindly, any advice on how to fix this error would be highly appreciated.

Building standalone classifier
mkdir -p build
rm -rf *.gcda
rm -rf *.gcno
clang -c -DTF_LITE_DISABLE_X86_NEON -Wall -I. -Isource -Iedge-impulse-sdk/ -Iedge-impulse-sdk/tensorflow -Iedge-impulse-sdk/third_party -Iedge-impulse-sdk/third_party/flatbuffers -Iedge-impulse-sdk/third_party/flatbuffers/include -Iedge-impulse-sdk/third_party/flatbuffers/include/flatbuffers -Iedge-impulse-sdk/third_party/gemmlowp/ -Iedge-impulse-sdk/third_party/gemmlowp/fixedpoint -Iedge-impulse-sdk/third_party/gemmlowp/internal -Iedge-impulse-sdk/third_party/ruy -Imodel-parameters -Itflite-model -Iedge-impulse-sdk/anomaly -Iedge-impulse-sdk/classifier -Iedge-impulse-sdk/dsp -Iedge-impulse-sdk/dsp/kissfft -Iedge-impulse-sdk/porting -lc++ -lm  edge-impulse-sdk/tensorflow/lite/c/common.c -o build/common.o
clang: warning: -lc++: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
clang++ -DTF_LITE_DISABLE_X86_NEON -std=c++11 -Wall -I. -Isource -Iedge-impulse-sdk/ -Iedge-impulse-sdk/tensorflow -Iedge-impulse-sdk/third_party -Iedge-impulse-sdk/third_party/flatbuffers -Iedge-impulse-sdk/third_party/flatbuffers/include -Iedge-impulse-sdk/third_party/flatbuffers/include/flatbuffers -Iedge-impulse-sdk/third_party/gemmlowp/ -Iedge-impulse-sdk/third_party/gemmlowp/fixedpoint -Iedge-impulse-sdk/third_party/gemmlowp/internal -Iedge-impulse-sdk/third_party/ruy -Imodel-parameters -Itflite-model -Iedge-impulse-sdk/anomaly -Iedge-impulse-sdk/classifier -Iedge-impulse-sdk/dsp -Iedge-impulse-sdk/dsp/kissfft -Iedge-impulse-sdk/porting -lc++ -lm  source/*.cpp edge-impulse-sdk/dsp/kissfft/*.cpp edge-impulse-sdk/dsp/dct/*.cpp edge-impulse-sdk/tensorflow/lite/kernels/*.cc edge-impulse-sdk/tensorflow/lite/kernels/internal/*.cc edge-impulse-sdk/tensorflow/lite/micro/kernels/*.cc edge-impulse-sdk/tensorflow/lite/micro/*.cc edge-impulse-sdk/tensorflow/lite/micro/memory_planner/*.cc edge-impulse-sdk/tensorflow/lite/core/api/*.cc ./edge-impulse-sdk/dsp/memory.cpp edge-impulse-sdk/porting/posix/*.c* build/common.o -o build/edge-impulse-standalone
/usr/bin/ld: cannot find -lc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Makefile.tflite:36: recipe for target 'build' failed
make: *** [build] Error 1

回答1:


Replace clang by clang++ or g++. Then -lc++ becomes "automagically" linked.

Of course, spend a few days reading the documentation of GCC and of Clang (and of ld from binutils; since both clang++ and g++ are running ld). Read carefully about invoking GCC. The order of program arguments to g++ (and also to clang++) are important.

Since you use GNU make, you obviously need to spend a day reading its documentation.

PS. Budget perhaps a week of work in reading documentation.




回答2:


I think your compile is instructing clang to use also the LLVM standard c++ library. That is not strictly required in all scenarios, but can be a good choice. You can read more about this library implementation on the libc++ website. Basically, its a more modern version of what gcc uses the GNU standard c++ library libstdc++ for.

To control the choice of the standard c++ library, typically the compiler flag -stdlib=xxx is used. In your case this seems to be set to libc++.

The libc++ development files are not installed along with clang by default. So its well possible your installation is just missing the libraries to link with.

On Ubuntu, with an upstream clang from llvm.org, you can install the libraries for example with (replace 11 with your actual version):

sudo apt install libc++-11-dev libc++abi-11-dev


来源:https://stackoverflow.com/questions/62612405/usr-bin-ld-cannot-find-lc

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