qbs dylib:未加载库,未找到图像

qbs dylib: library not loaded, image not found

我正在尝试使用 leap motion 库构建一个 qbs 项目,但是 运行 该项目出现以下错误:

dyld: Library not loaded: @loader_path/libLeap.dylib
Referenced from: /Users/pball/Work/Code/Qt/build-LeapTest-Desktop-Debug/qtc_Desktop_95cbad6a-debug/install-root/LeapTest
Reason: image not found

我的 qbs 文件:

import qbs
CppApplication {
consoleApplication: true
files: "main.cpp"

Group {     // Properties for the produced executable
    fileTagsFilter: product.type
    qbs.install: true
}

cpp.includePaths: [".","/Users/pball/LeapSDK/include"]
cpp.libraryPaths: ["/Users/pball/LeapSDK/lib"]

cpp.dynamicLibraries: "Leap"
}

libLeap.dylib 就在那个位置。

使用 Qt 5.6.0

刚开始使用 qbs,非常感谢任何帮助/指点。

这不是特定于 qbs 的问题,而是需要了解动态库在 macOS 上的加载方式。请查看 dyld and Run-Path Dependent Libraries.

上的文档

也就是说,根据你依赖的共享库的安装名称libLeap.dylib,如果你将它复制到与你的 LeapTest 应用程序二进制文件相同的目录,它应该会成功加载。