ninja: error: ‘/opt/homebrew/Cellar/opensslxxx/xx/lib/libssl.dylib

复制代码
Run Build Command(s): /Applications/CLion.app/Contents/bin/ninja/mac/aarch64/ninja -v -j 14 MediaServer
ninja: error: '/opt/homebrew/Cellar/openssl@3/3.3.2/lib/libssl.dylib', needed by '/Users/xxx/CLionProjects/ZLMediaKit/release/darwin/Debug/MediaServer', missing and no known rule to make it 

解决方案

这个错误表明构建过程需要一个 OpenSSL 动态库 (libssl.dylib),但路径 /opt/homebrew/Cellar/openssl@3/3.3.2/lib/libssl.dylib 下的文件不存在。可能的原因包括:

1.OpenSSL 未安装或路径不正确。

2.项目构建时引用的 OpenSSL 版本与系统中实际的版本不匹配。

解决步骤

  1. 检查 OpenSSL 是否已安装
    运行以下命令检查 OpenSSL 版本:

    brew list openssl@3

如果未安装,可以安装:

复制代码
brew install openssl@3
  1. 验证路径是否正确

    如果文件不存在,请查找 OpenSSL 动态库的实际路径:

  2. 修复路径引用

如果 OpenSSL 已安装但路径不一致,您可以修改 CMake 配置文件或环境变量,确保构建过程找到正确的 OpenSSL 路径。

eg.

复制代码
build % brew list openssl@3
 
/opt/homebrew/Cellar/openssl@3/3.4.0/.bottle/etc/ (9 files)
/opt/homebrew/Cellar/openssl@3/3.4.0/bin/c_rehash
/opt/homebrew/Cellar/openssl@3/3.4.0/bin/openssl
/opt/homebrew/Cellar/openssl@3/3.4.0/include/openssl/ (141 files)
/opt/homebrew/Cellar/openssl@3/3.4.0/lib/libcrypto.3.dylib
/opt/homebrew/Cellar/openssl@3/3.4.0/lib/libssl.3.dylib
/opt/homebrew/Cellar/openssl@3/3.4.0/lib/cmake/ (2 files)
/opt/homebrew/Cellar/openssl@3/3.4.0/lib/engines-3/ (3 files)
/opt/homebrew/Cellar/openssl@3/3.4.0/lib/ossl-modules/legacy.dylib
/opt/homebrew/Cellar/openssl@3/3.4.0/lib/pkgconfig/ (3 files)
/opt/homebrew/Cellar/openssl@3/3.4.0/lib/ (4 other files)
/opt/homebrew/Cellar/openssl@3/3.4.0/sbom.spdx.json
/opt/homebrew/Cellar/openssl@3/3.4.0/share/doc/ (879 files)
/opt/homebrew/Cellar/openssl@3/3.4.0/share/man/ (6182 files) 
/opt/homebrew/Cellar/openssl@3/3.4.0

从输出来看,我的 OpenSSL 版本是 3.4.0,而项目的构建过程试图使用的是 3.3.2,这导致了路径不匹配问题。

解决办法

  1. 将 3.4.0 的动态库链接到期望的 3.3.2 目录下
  • 执行以下命令

    mkdir -p /opt/homebrew/Cellar/openssl@3/3.3.2/lib
    ln -sf /opt/homebrew/Cellar/openssl@3/3.4.0/lib/libssl.3.dylib /opt/homebrew/Cellar/openssl@3/3.3.2/lib/libssl.dylib
    ln -sf /opt/homebrew/Cellar/openssl@3/3.4.0/lib/libcrypto.3.dylib /opt/homebrew/Cellar/openssl@3/3.3.2/lib/libcrypto.dylib

  • 然后重新构建项目:

    cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build
    cmake --build build

  1. 更新 CMake 配置文件

更好的方法是显式地告诉 CMake 使用 3.4.0 的路径。

  • 修改 CMakeLists.txt,在项目的 CMakeLists.txt 文件中添加以下行:

set(OPENSSL_ROOT_DIR "/opt/homebrew/opt/openssl@3")

set(OPENSSL_LIBRARIES "/opt/homebrew/opt/openssl@3/lib")

set(OPENSSL_INCLUDE_DIR "/opt/homebrew/opt/openssl@3/include")

  • 重新生成构建文件

    rm -rf build
    cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build
    cmake --build build

  1. 设置环境变量

如果无法修改 CMakeLists.txt,可以设置环境变量,临时修复路径问题。

运行以下命令:

复制代码
export OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)
export OPENSSL_LIBRARIES=$OPENSSL_ROOT_DIR/lib
export OPENSSL_INCLUDE_DIR=$OPENSSL_ROOT_DIR/include
  • 重新生成构建文件

    cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build
    cmake --build build

相关推荐
虾球xz35 分钟前
游戏引擎学习第277天:稀疏实体系统
c++·学习·游戏引擎
想睡hhh39 分钟前
c++进阶——哈希表的实现
开发语言·数据结构·c++·散列表·哈希
行思理41 分钟前
JIT+Opcache如何配置才能达到性能最优
c++·php·jit
南风与鱼1 小时前
STL详解 - 红黑树模拟实现map与set
c++·红黑树封装map和set
虾球xz3 小时前
游戏引擎学习第276天:调整身体动画
c++·学习·游戏引擎
虾球xz3 小时前
游戏引擎学习第275天:将旋转和剪切传递给渲染器
c++·学习·游戏引擎
虾球xz8 小时前
游戏引擎学习第268天:合并调试链表与分组
c++·学习·链表·游戏引擎
fpcc9 小时前
跟我学c++高级篇——模板元编程之十三处理逻辑
c++
格林威9 小时前
Baumer工业相机堡盟工业相机的工业视觉中为什么偏爱“黑白相机”
开发语言·c++·人工智能·数码相机·计算机视觉
Dream it possible!10 小时前
LeetCode 热题 100_只出现一次的数字(96_136_简单_C++)(哈希表;哈希集合;排序+遍历;位运算)
c++·leetcode·位运算·哈希表·哈希集合