ld:警告:重新导出的库 libunwind.1.dylib 无法与任何父库匹配

问题描述 投票:0回答:1

我正在尝试在 macOS Sonoma (14.6) 上设置 C++20 开发环境。

我已经使用 Homebrew 安装了

llvm
cmake
clang
版本信息:

Homebrew clang version 18.1.8
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin

~/.zshenv

中的C++配置:

export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) path=('/opt/homebrew/opt/llvm/bin' $path) # --> this is at the bottom of the file
该项目在一个文件中实现和测试,目录结构如下:

. ├── CMakeLists.txt ├── LICENSE.txt ├── Makefile ├── README.md ├── scripts │   └── build.sh └── src ├── foo │ ├── file1.cpp │ └── file2.cpp └── bar ├── file3.cpp └── file4.cpp

CMakeLists.txt

 看起来像:

cmake_minimum_required(VERSION 3.30) project(algorithms) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) enable_testing() # Find all source files recursively file(GLOB_RECURSE SOURCE_FILES "src/**/*.cpp") # Create executables for each source file foreach(src_file ${SOURCE_FILES}) # Extract file name without extension get_filename_component(exec_name ${src_file} NAME_WE) # Only create executables from files that contain a main function if(NOT "${exec_name}" STREQUAL "main") add_executable(${exec_name} ${src_file}) # Register a test for each executable add_test(NAME ${exec_name} COMMAND ${exec_name}) endif() endforeach()
在执行项目时,我看到以下警告:

ld: warning: reexported library with install name '/opt/homebrew/opt/llvm/lib/libunwind.1.dylib' found at '/opt/homebrew/Cellar/llvm/18.1.8/lib/libunwind.1.0.dylib' couldn't be matched with any parent library and will be linked directly
我尝试注释掉 

export LDFLAGS

 中的 
.zshenv
 指令,但仍然看到同样的事情。

如何修复此问题以消除警告?

c++ clang llvm
1个回答
0
投票
更新

LDFLAGS

至:

LDFLAGS+=" -L/opt/homebrew/opt/llvm/lib/c++ -L/opt/homebrew/opt/llvm/lib -lunwind"
基于跑步

brew info llvm

© www.soinside.com 2019 - 2024. All rights reserved.