MacOS使用ZThread错误 lazy symbol binding failed

OS: macos

使用编译命令:

g++ -Wall -g -o a a.cpp  -lzthread

编译顺利通过,运行时出现如下报错:

dyld: lazy symbol binding failed: Symbol not found: _MPCreateCriticalRegion Referenced from: /usr/local/lib/libZThread-2.3.2.dylib Expected in: flat namespace

dyld: Symbol not found: _MPCreateCriticalRegion Referenced from: /usr/local/lib/libZThread-2.3.2.dylib Expected in: flat namespace

Trace/BPT trap: 5

解决方法: 需要在编译时加入carbon framework:

g++ -Wall -g -o a a.cpp -framework Carbon -lzthread