/usr/bin/ld: cannot find -lc++
/usr/bin/ld: cannot find -lc++
我正在这里按照构建音频分类器的教程进行操作,当到达运行 sh build.sh 的步骤时,我收到cannot find -lc++
错误。
善意地,有关如何修复此错误的任何建议将不胜感激。
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
我认为您的构建配置告诉编译器使用来自 clang (LLVM( 的标准 c++ 库。
这是一个可能的选择,当然不是一个坏选择。但是,它并不是标准 c++ 库的唯一选择。最后有两个常用的标准 c++ 库:使用非常广泛的 GNU 标准 c++ 库 libstdc++,以及稍微现代一点的 libc++。两个库都很好。但是由于GNU版本更常用(截至撰写本文时(,因此使用这个版本可能会遇到更少的问题。
若要控制标准 c++ 库的选择,可以使用编译器标志-stdlib=xxx
。在您的情况下,此标志似乎设置为libc++
,或者您的编译器默认设置为libc++
。
请注意,一个常见问题可能是默认情况下,libc++
开发文件未与 clang 编译器一起安装。因此,您需要做的就是安装缺少的库,一切正常。
您至少有两个选项:
- 安装 LLVM 标准 c++ 库,以防丢失。在 Ubuntu 上,使用 llvm.org 的上游 clang,您可以安装这些库,例如 (将
15
替换为您的实际版本(:
sudo apt install libc++-15-dev libc++abi-15-dev
- 选择其他标准 c++ 库。要使用更常见的GNU标准c++库
libstdc++
,通常只需从构建配置中删除-stdlib=libc++
标志就足够了,例如从CMakeLists.txt
中删除。也可能您的编译器默认使用libc++
,在这种情况下,您需要添加标志-stdlib=libstdc++
以主动选择 GNU 版本。
将clang
替换为clang++
或g++
。然后-lc++
变得"自动"链接。
当然,花几天时间阅读GCC和Clang的文档(以及binutils的ld
文档;因为clang++
和g++
都在运行ld
(。仔细阅读有关调用 GCC 的信息。程序参数的顺序g++
(以及clang++
(很重要。
由于你使用GNU make,你显然需要花一天时间阅读它的文档。
预算也许是一周的阅读文档的工作。
相关文章:
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- OpenMP卸载说'fatal error: could not find accel/nvptx-none/mkoffload'
- 使用.find函数在c++中查找字符和另一个字符之间的大小
- 在 QVector<std::unique_ptr 上使用 std::find<Type>>
- 错误"Could not find Boost"(缺少:上下文标头)
- /usr/bin/ld: cannot find -lc++
- std::find,返回所有找到的值的替代方法,而不仅仅是存在重复的向量的第一个值
- 使用 find 解析文件会给出不同文件的奇怪结果
- 在 ifcondition al中 find() C++ STL 中的 == a.end() 有什么用?
- Cannot find -lglad
- "Cannot find -l<directory>"错误 - CMake
- 为什么在向量上使用 std::find() 时会出现错误?
- 为什么映射插入和 map.find() 的单次迭代比插入和 map.find() 的两次单独迭代慢得多
- C++ find() 在存储为变量时返回不同的值
- set::find 查找不存在的元素
- 使用 std::find 时没有匹配的函数调用错误
- 在先前调用 string::find 后添加内存分配和内存集会导致它返回 npos.为什么?
- Windows cannot find MinGW
- find() stl in vector in c++
- std::set<Key,Compare,Allocator>::find() 函数使用"<"运算符而不是"=="运算符背后的直觉是什么?