macos 下 goland # runtime/cgo ld: library not found for -lpthread clang-13: error: linker 问题解决

笔记 / 2022-01-15

问题

在使用goland进行debug时,报错 无法进行调试

# runtime/cgo
ld: library not found for -lpthread
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)

原因

因为使用了cgo 找不到依赖库,我们需要手动指定。

解决

bash.rc

export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
export LD_LIBRARY_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/lib
export LIBRARY_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/lib