我有一个由 cmake 构建的子模块,并在 qbs 脚本中成功构建它(见下面的代码)。
Product {
name: "mylib"
type: ["staticlibrary"]
// define buildScript, outputPath, libPrefix, libExt, cmakeBuildType, cmakeBuildConfig
// Note that outputPath is inside mylib folder, not qbs's build directory
Rule {
multiplex: true
outputArtifacts: [
{
filePath: product.outputPath + product.libPrefix + "lib1static" + product.libExt,
fileTags: ["staticlibrary"]
},
{
filePath: product.outputPath + product.libPrefix + "lib2static" + product.libExt,
fileTags: ["staticlibrary"]
}
]
outputFileTags: ["staticlibrary"]
prepare: {
var cmd = new Command(product.buildScript, [product.outputPath, product.cmakeBuildType, product.cmakeBuildConfig]);
cmd.description = "cmake generate mylib";
cmd.workingDirectory = product.sourceDirectory + "/mylib/build_cmake";
return [cmd];
}
}
但是,有时 qbs 会删除“lib1static”和“lib2static”,并且在链接时出现此错误:
clang: error: no such file or directory: '<path>/lib1static.a'
clang: error: no such file or directory: '<path>/lib2static.a'
我试图调试,但仍然不知道为什么。第一次构建可以成功,所有输出库都已构建,但在下一次构建中,所有库都消失了。
这里的任何人都可以解释并告诉我这种情况下哪个是最佳实践吗?