编译报错ld.lld: error: unable to find library

Ubuntu编译某源码时,碰到问题:

clang -fuse-ld=lld -o ../bin/DevicePath  DevicePath.o UefiDevicePathLib.o DevicePathFromText.o  DevicePathUtilities.o -L../libs -lCommon -luuid
ld.lld: error: unable to find library -luuid
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

在VS Code添加对pthread_create的支持_阅后即奋的博客-CSDN博客中写过-l的用法。

那么这里就很明显,链接libuuid库时,找不到。

解决方案:下载libuuid库

apt-cache search libuuid

 得到如下的搜索结果:

libuuid-perl - Perl extension for using UUID interfaces as defined in e2fsprogs
libuuid1 - Universally Unique ID library
uuid-dev - Universally Unique ID library - headers and static libraries
uuid-runtime - runtime components for the Universally Unique ID library
libdata-uuid-libuuid-perl - uuid.h based UUID generation module
libuuid-tiny-perl - pure Perl module to generate v1, v3, v4, and v5 UUIDs
libuuidm-ocaml-dev - Universally unique identifiers for OCaml
php-uuid - PHP UUID extension

选择一个库,这里我选择的是uuid-dev

sudo apt install uuid-dev

看一下安装后的效果,在/usr路径下执行:

du -a | grep libuuid

得到如下的搜索结果,库安装完成。

4    ./share/doc/libuuid1/changelog.Debian.gz
20    ./share/doc/libuuid1/copyright
28    ./share/doc/libuuid1
44    ./lib/x86_64-linux-gnu/libuuid.a
0    ./lib/x86_64-linux-gnu/libuuid.so

你可能感兴趣的:(Ubuntu杂记,linux)