“/usr/bin/ld: cannot find -lopenblas” error in Caffe compilation

本文介绍了解决在编译libcaffe过程中遇到的链接OpenBLAS库失败的问题。通过安装必要的库文件如liblapack-dev, liblapack3等,成功解决了ld找不到-lopenblas的问题。
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so
/usr/bin/ld: cannot find -lopenblas
collect2: ld devolvió el estado de salida 1
make: *** [.build_release/lib/libcaffe.so] Error 1


解决方案:
apt install liblapack-dev liblapack3 libopenblas-base libopenblas-dev

(Flightgpt) lixing@DESKTOP-2PJK7EV:~/FlightGPT/vllm$ uv pip install -e . Using Python 3.10.18 environment at: /home/lixing/anaconda3/envs/Flightgpt Resolved 142 packages in 8m 21s × Failed to build `vllm @ file:///home/lixing/FlightGPT/vllm` ├─▶ The build backend returned an error ╰─▶ Call to `setuptools.build_meta.build_editable` failed (exit status: 1) [stdout] running editable_wheel creating /home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm.egg-info writing /home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm.egg-info/PKG-INFO writing dependency_links to /home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm.egg-info/dependency_links.txt writing entry points to /home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm.egg-info/entry_points.txt writing requirements to /home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm.egg-info/requires.txt writing top-level names to /home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm.egg-info/top_level.txt writing manifest file '/home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' writing manifest file '/home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm.egg-info/SOURCES.txt' creating '/home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm-0.11.0rc2.dev71+ge18b714b2.cu118.dist-info' creating /home/lixing/.cache/uv/builds-v0/.tmpzogBmT/.tmp-n_t_37zd/vllm-0.11.0rc2.dev71+ge18b714b2.cu118.dist-info/WHEEL running build_py running build_ext -- The CXX compiler identification is GNU 9.4.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Build type: RelWithDebInfo -- Target device: cuda -- Found Python: /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/bin/python (found version "3.10.18") found components: Interpreter Development.Module Development.SABIModule -- Found python matching: /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/bin/python. -- Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (found version "11.8") -- Configuring incomplete, errors occurred! [stderr] /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/torch/_subclasses/functional_tensor.py:279: UserWarning: Failed to initialize NumPy: No module named 'numpy' (Triggered internally at /pytorch/torch/csrc/utils/tensor_numpy.cpp:81.) cpu = _conversion_method_template(device=torch.device("cpu")) /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools_scm/_integration/version_inference.py:51: UserWarning: version of None already set warnings.warn(self.message) CMake Warning at /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/torch/share/cmake/Caffe2/public/cuda.cmake:31 (message): PyTorch: CUDA cannot be found. Depending on whether you are building PyTorch or a PyTorch dependent library, the next warning / error will give you more info. Call Stack (most recent call first): /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/torch/share/cmake/Caffe2/Caffe2Config.cmake:86 (include) /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:68 (find_package) CMakeLists.txt:84 (find_package) CMake Error at /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/torch/share/cmake/Caffe2/Caffe2Config.cmake:90 (message): Your installed Caffe2 version uses CUDA but I cannot find the CUDA libraries. Please set the proper CUDA prefixes and / or install CUDA. Call Stack (most recent call first): /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:68 (find_package) CMakeLists.txt:84 (find_package) Traceback (most recent call last): File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 139, in run self._create_wheel_file(bdist_wheel) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 340, in _create_wheel_file files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 263, in _run_build_commands self._run_build_subcommands() File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 290, in _run_build_subcommands self.run_command(name) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "<string>", line 268, in run File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 99, in run _build_ext.run(self) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 368, in run self.build_extensions() File "<string>", line 230, in build_extensions File "<string>", line 208, in configure File "/home/lixing/anaconda3/envs/Flightgpt/lib/python3.10/subprocess.py", line 369, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '/home/lixing/FlightGPT/vllm', '-G', 'Ninja', '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DVLLM_TARGET_DEVICE=cuda', '-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache', '-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache', '-DCMAKE_HIP_COMPILER_LAUNCHER=ccache', '-DVLLM_PYTHON_EXECUTABLE=/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/bin/python', '-DVLLM_PYTHON_PATH=/home/lixing/slam/Fast-LIO2/devel/lib/python3/dist-packages:/opt/ros/noetic/lib/python3/dist-packages:/home/lixing/anaconda3/envs/Flightgpt/lib/python310.zip:/home/lixing/anaconda3/envs/Flightgpt/lib/python3.10:/home/lixing/anaconda3/envs/Flightgpt/lib/python3.10/lib-dynload:/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages:/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_vendor', '-DFETCHCONTENT_BASE_DIR=/home/lixing/FlightGPT/vllm/.deps', '-DNVCC_THREADS=1', '-DCMAKE_JOB_POOL_COMPILE:STRING=compile', '-DCMAKE_JOB_POOLS:STRING=compile=24', '-DCMAKE_CUDA_COMPILER=/usr/local/cuda-11.8/bin/nvcc']' returned non-zero exit status 1. /home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/dist.py:1021: _DebuggingTips: Problem in editable installation. !! ******************************************************************************** An error happened while installing `vllm` in editable mode. The following steps are recommended to help debug this problem: - Try to install the project normally, without using the editable mode. Does the error still persist? (If it does, try fixing the problem before attempting the editable mode). - If you are using binary extensions, make sure you have all OS-level dependencies installed (e.g. compilers, toolchains, binary libraries, ...). - Try the latest version of setuptools (maybe the error was already fixed). - If you (or your project dependencies) are using any setuptools extension or customization, make sure they support the editable mode. After following the steps above, if the problem still persists and you think this is related to how setuptools handles editable installations, please submit a reproducible example (see https://stackoverflow.com/help/minimal-reproducible-example) to: https://github.com/pypa/setuptools/issues See https://setuptools.pypa.io/en/latest/userguide/development_mode.html for details. ******************************************************************************** !! cmd_obj.run() Traceback (most recent call last): File "<string>", line 11, in <module> File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/build_meta.py", line 468, in build_editable return self._build_with_temp_dir( File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/build_meta.py", line 404, in _build_with_temp_dir self.run_setup() File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/build_meta.py", line 317, in run_setup exec(code, locals()) File "<string>", line 648, in <module> File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup return distutils.core.setup(**attrs) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 186, in setup return run_commands(dist) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 202, in run_commands dist.run_commands() File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands self.run_command(cmd) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 139, in run self._create_wheel_file(bdist_wheel) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 340, in _create_wheel_file files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 263, in _run_build_commands self._run_build_subcommands() File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 290, in _run_build_subcommands self.run_command(name) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "<string>", line 268, in run File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 99, in run _build_ext.run(self) File "/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 368, in run self.build_extensions() File "<string>", line 230, in build_extensions File "<string>", line 208, in configure File "/home/lixing/anaconda3/envs/Flightgpt/lib/python3.10/subprocess.py", line 369, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', '/home/lixing/FlightGPT/vllm', '-G', 'Ninja', '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DVLLM_TARGET_DEVICE=cuda', '-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache', '-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache', '-DCMAKE_HIP_COMPILER_LAUNCHER=ccache', '-DVLLM_PYTHON_EXECUTABLE=/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/bin/python', '-DVLLM_PYTHON_PATH=/home/lixing/slam/Fast-LIO2/devel/lib/python3/dist-packages:/opt/ros/noetic/lib/python3/dist-packages:/home/lixing/anaconda3/envs/Flightgpt/lib/python310.zip:/home/lixing/anaconda3/envs/Flightgpt/lib/python3.10:/home/lixing/anaconda3/envs/Flightgpt/lib/python3.10/lib-dynload:/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages:/home/lixing/.cache/uv/builds-v0/.tmpZyFBeT/lib/python3.10/site-packages/setuptools/_vendor', '-DFETCHCONTENT_BASE_DIR=/home/lixing/FlightGPT/vllm/.deps', '-DNVCC_THREADS=1', '-DCMAKE_JOB_POOL_COMPILE:STRING=compile', '-DCMAKE_JOB_POOLS:STRING=compile=24', '-DCMAKE_CUDA_COMPILER=/usr/local/cuda-11.8/bin/nvcc']' returned non-zero exit status 1. hint: This usually indicates a problem with the package or the build environment. (Flightgpt) lixing@DESKTOP-2PJK7EV:~/FlightGPT/vllm$
09-25
<think>我们面对的是两个主要问题: 1. /usr/bin/ld: cannot find -lsecurec (找不到名为libsecurec的库) 2. error: ld returned 1 exit status (链接器返回错误) 根据引用[1][2][3]中提供的解决思路,通常这类问题的解决方法是: - 确保库已安装 - 创建正确的符号链接 - 或者将库路径添加到链接器的搜索路径中 具体步骤: 步骤1:确认库文件是否存在 - 在系统中查找名为`libsecurec.so`或`libsecurec.a`的文件。可以使用以下命令: find / -name "libsecurec*" 2>/dev/null 步骤2:如果找到库文件,确保链接器能够找到 - 方法1:将库文件所在目录添加到链接器搜索路径中 在编译命令中加入`-L<库所在目录>`,例如:`-L/usr/local/lib` - 方法2:将库所在目录添加到`/etc/ld.so.conf`或`/etc/ld.so.conf.d/`下的配置文件中,然后运行`sudo ldconfig` - 方法3:创建符号链接到链接器默认搜索的目录(如`/usr/lib`或`/usr/local/lib`) 例如:`sudo ln -s /path/to/libsecurec.so /usr/lib/libsecurec.so` 步骤3:如果未找到库文件,则需要安装该库 - 根据操作系统不同,安装对应的包。例如,在CentOS上可能叫做`libsecurec`,在Ubuntu上可能叫做`libsecurec-dev`(具体包名需要查询) - 如果官方源没有,可能需要从第三方下载或从源码编译 步骤4:确认库文件名规范 - 链接器查找的库名是`-lsecurec`,对应的文件名是`libsecurec.so`(动态库)或`libsecurec.a`(静态库)。确保文件命名正确。 步骤5:检查编译命令 - 确保在编译命令中正确指定了库,例如:`gcc main.c -o main -lsecurec` 步骤6:如果问题仍然存在,检查库的架构是否匹配(如64位系统需要64位库) 根据引用[1][2][3]中的例子,我们采取的典型解决方法是: - 创建符号链接(如引用[1]) - 安装开发包(如引用[3]) 因此,针对`/usr/bin/ld: cannot find -lsecurec`,可以尝试: 假设我们在查找中发现库文件位于`/usr/lib64/libsecurec.so.1`,则可以创建符号链接: sudo ln -s /usr/lib64/libsecurec.so.1 /usr/lib/libsecurec.so 或者,如果库文件在`/usr/local/lib`下,则可以在编译时添加`-L/usr/local/lib`。 如果未安装该库,则需要安装。例如,在CentOS上,可以尝试: yum install libsecurec 在Ubuntu/Debian上,可以尝试: apt install libsecurec-dev (注意:包名可能不同,需要根据实际情况确定) 注意:`libsecurec`可能是华为的安全C库,如果从官方下载,可能需要手动安装。 总结步骤: 1. 查找库文件:`find / -name "libsecurec*" 2>/dev/null` 2. 如果找到: 创建符号链接到标准库目录(如/usr/lib)或使用`-L`指定目录 3. 如果没找到: 安装对应的库(通过包管理或手动安装) 4. 重新运行编译命令 最后,确保编译命令正确,并且没有其他链接错误。 如果按照以上步骤操作,通常可以解决该问题。 相关问题: 1. 如何检查Linux系统中是否安装了某个库? 2. 如何在Linux中添加库的搜索路径? 3. 如何为不同的Linux发行版安装开发库? </think> ### 解决编译错误 `/usr/bin/ld: cannot find -lsecurec` 和 `error: ld returned 1 exit status` 该错误表示链接器(ld)无法找到名为 `libsecurec` 的库文件,导致编译失败。以下是系统级的解决方案,按优先级排序: --- #### 1. **确认库文件是否存在** 首先检查系统中是否安装了该库: ```bash find / -name "libsecurec*" 2>/dev/null ``` - 如果输出类似 `/usr/lib/libsecurec.so.1`,说明库已存在但链接器未识别 - **无输出**表示库未安装(跳到步骤3) --- #### 2. **修复库路径或符号链接**(库存在时) - **添加库搜索路径** 在编译命令中显式指定库路径(假设库在 `/usr/local/lib`): ```bash gcc your_code.c -o output -L/usr/local/lib -lsecurec ``` 或在 `Makefile` 中添加: ```makefile LDFLAGS += -L/usr/local/lib -lsecurec ``` - **创建符号链接**(解决版本不匹配) 如果找到 `libsecurec.so.1` 但链接器需要 `libsecurec.so`: ```bash sudo ln -s /usr/lib/libsecurec.so.1 /usr/lib/libsecurec.so ``` 参考类似问题解决方案[^1][^2] - **刷新动态库缓存** ```bash sudo ldconfig ``` --- #### 3. **安装缺失的库**(库不存在时) - **通过包管理器安装** - CentOS/RHEL: ```bash sudo yum install libsecurec # 或搜索 yum search libsecurec ``` - Ubuntu/Debian: ```bash sudo apt install libsecurec-dev ``` - **手动安装**(若包管理器无提供) 1. 从官方源下载(如华为 openEuler 的[libsecurec](https://gitee.com/openeuler/libsecurec)) 2. 编译安装: ```bash tar -zxvf libsecurec.tar.gz cd libsecurec mkdir build && cd build cmake .. && make sudo make install ``` --- #### 4. **验证解决效果** 重新编译后检查: ```bash ldd your_executable | grep securec # 应显示 libsecurec.so => [路径] ``` --- #### 5. **排查其他常见问题** - **架构不匹配**:确保库与系统架构一致(32/64位) - **编译参数错误**:检查 `-lsecurec` 是否拼写正确 - **环境变量**:设置 `LD_LIBRARY_PATH`(临时方案): ```bash export LD_LIBRARY_PATH=/custom/lib/path:$LD_LIBRARY_PATH ``` > 📌 **关键提示**:`libsecurec` 是华为开发的安全 C 库,常见于 openEuler/HarmonyOS 生态。若在 Ubuntu/CentOS 编译华为相关项目,建议从[官方仓库](https://gitee.com/openeuler/libsecurec)获取源码编译[^3]。 --- ### 相关问题 1. 如何在 CMake 项目中正确链接第三方库(如 libsecurec)? 2. 编译时 `ld` 报错 "cannot find -lxxx" 的通用排查步骤有哪些? 3. 如何为 Linux 系统手动编译并安装缺失的动态库?
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值