问题描述
我遇到了CMake的问题,这使我损失了很多时间,而且我不确定如何解决它。 基本上,在我的MacOS计算机上,这个小脚本不起作用:
find_package(Python COMPONENTS Development)
add_executable(test "test.cpp")
target_link_libraries(test Python::Python)
其中test.cpp是一个简单的空主管道。
当我尝试运行test
时,我得到:
dyld: Library not loaded: @rpath/python3.framework/Versions/3.8/python3
Referenced from: /Users/path/to/test
Reason: image not found
Abort trap: 6
otool -l
向我展示了可执行文件中的rpath是:
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/python3.framework/Versions/3.8/lib
我尝试了许多不同的调试方式来调试这两个rpath的来源,但这使我无处可去。 即使链接到库的实际路径,我也会得到相同的结果:
target_link_libraries(test "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/python3.framework/Versions/3.8/lib/libpython3.8.dylib"
我知道我可以在我的机器上使用CMake命令更改rpath,但这对我来说似乎很棘手,并且可能不适用于其他配置。
findpython中是否有bug?还是我的python安装有问题?我对现在去哪里不知所措。而且我对导致这些路径出现的原因特别困惑,因为似乎没有迹象表明CMake配置文件中的路径。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)