Qt qbs project settings with library not found 编译报错
Qt qbs project settings with library not found compile error
我正在做一个有多个层次的项目。就个人而言,我是qbs的新手,内部关于qbs的文档和例子不多。
环境:
Qt5.6.1; Qt 创作者 4.01; Ubuntu16.04; Qbs 1.5.1
这是项目的层次结构。在顶层,它有 project.qbs:
import qbs
import qbs.File
Project{
var binaries = [
"component1/component1.qbs",
"component2/component2.qbs",
"subpro/subpro.qbs", // <- 1. the project I am working on
"ourlib/ourlib.qbs", // <- 2. the library I am using
]
return binaries
}
subpro.qbs 类似于:
import qbs
Project {
name: subpro
references:[
"app1/app1.qbs"
"app2/app2.qbs"
"myapp/myapp.qbs" //<- 3. the application I am working on
]
}
myapp.qbs 就像:
import qbs
CppApplication{
type: "application"
name: "myapp"
Group{
name: "project-install"
fileTagsFilter: "application"
qbs.install: false
qbs.install: "bin"
}
Depends {name:"cpp"}
Depends {name:"blah1"}
Depends {name:"ourlib"}
cpp.libraryPaths:["path_of_lib3rdParty"] // 4. set the 3rd party lib path
cpp.staticLibraries:["lib3rdParty.a"] // 5. set the 3rd party lib name
files["myapp.cpp","f2"...]
}
最后是我们的库的 qbs:
import qbs
DynamicLibrary{
name: "ourlib"
Group{
name: "project-install"
fileTagsFilter: "dynamiclibrary"
qbs.install: false
qbs.installDir: "debug"
}
Depends {name: "cpp"}
cpp.includePath:["..."]
cpp.libraryPaths:["path_of_lib3rdParty"] // 6. same as 4
cpp.staticLibraries:["lib3rdParty.a"] // 7. same as 5
}
当我在运行"qbs debug"项目根文件夹下。
qbs 显示:
linking ourlib.so
compiling myapp.cpp
ERROR: ...
/usr/bin/ld: cannot find -llib3rdParty_s.a
因此,根据错误消息,qbs 未能构建 myapp.cpp 并试图在 myapp 项目中找到 lib3rdParty。我添加了 4 和 5,仍然有同样的错误。似乎 6 和 7 是正确的,因为 ourlib.so 没有链接错误。我应该如何配置 qbs 以使构建过程正常运行?
另一个问题是关于关键字"references"。我可以在项目的任何级别引用其他 qbs 文件吗?它是如何工作的?我也有关于 "Depends" 的相同问题。
谢谢
容
cpp.dynamicLibraries
和 cpp.staticLibraries
属性采用 names 库列表 linked,即不带 lib
前缀或 .so
后缀。
例如,您将使用:
cpp.libraryPaths: ["/home/r0ng/tools/myapp/libs/relic/lib"]
cpp.dynamicLibraries: ["relic"]
但是,由于您已经有了想要 link 的动态库的完整文件路径,因此您可以简单地传递完整文件路径而无需指定 cpp.libraryPaths
,就像这样:
cpp.dynamicLibraries: ["/home/r0ng/tools/myapp/libs/relic/lib/librelic.so"]
第二种方法是首选,因为它指定了要 link 的确切库,而不是依赖于可能不一定选择您期望的库类型的搜索路径(如果静态和动态版本存在)。
我承认应该更好地记录我们的 cpp.dynamicLibraries
和 cpp.staticLibraries
属性,以解释它们的预期用途。
关于references
,是的,您可以引用任何文件路径,而不考虑其文件系统位置。
关于 Depends
,该项目的 name
属性 指定要创建依赖项的产品或模块的名称。这样的产品或模块必须已经存在于您的项目树中,例如由于使用 qbsSearchPaths
或 references
属性而加载。
我正在做一个有多个层次的项目。就个人而言,我是qbs的新手,内部关于qbs的文档和例子不多。
环境:
Qt5.6.1; Qt 创作者 4.01; Ubuntu16.04; Qbs 1.5.1
这是项目的层次结构。在顶层,它有 project.qbs:
import qbs
import qbs.File
Project{
var binaries = [
"component1/component1.qbs",
"component2/component2.qbs",
"subpro/subpro.qbs", // <- 1. the project I am working on
"ourlib/ourlib.qbs", // <- 2. the library I am using
]
return binaries
}
subpro.qbs 类似于:
import qbs
Project {
name: subpro
references:[
"app1/app1.qbs"
"app2/app2.qbs"
"myapp/myapp.qbs" //<- 3. the application I am working on
]
}
myapp.qbs 就像:
import qbs
CppApplication{
type: "application"
name: "myapp"
Group{
name: "project-install"
fileTagsFilter: "application"
qbs.install: false
qbs.install: "bin"
}
Depends {name:"cpp"}
Depends {name:"blah1"}
Depends {name:"ourlib"}
cpp.libraryPaths:["path_of_lib3rdParty"] // 4. set the 3rd party lib path
cpp.staticLibraries:["lib3rdParty.a"] // 5. set the 3rd party lib name
files["myapp.cpp","f2"...]
}
最后是我们的库的 qbs:
import qbs
DynamicLibrary{
name: "ourlib"
Group{
name: "project-install"
fileTagsFilter: "dynamiclibrary"
qbs.install: false
qbs.installDir: "debug"
}
Depends {name: "cpp"}
cpp.includePath:["..."]
cpp.libraryPaths:["path_of_lib3rdParty"] // 6. same as 4
cpp.staticLibraries:["lib3rdParty.a"] // 7. same as 5
}
当我在运行"qbs debug"项目根文件夹下。 qbs 显示:
linking ourlib.so
compiling myapp.cpp
ERROR: ...
/usr/bin/ld: cannot find -llib3rdParty_s.a
因此,根据错误消息,qbs 未能构建 myapp.cpp 并试图在 myapp 项目中找到 lib3rdParty。我添加了 4 和 5,仍然有同样的错误。似乎 6 和 7 是正确的,因为 ourlib.so 没有链接错误。我应该如何配置 qbs 以使构建过程正常运行?
另一个问题是关于关键字"references"。我可以在项目的任何级别引用其他 qbs 文件吗?它是如何工作的?我也有关于 "Depends" 的相同问题。
谢谢
容
cpp.dynamicLibraries
和 cpp.staticLibraries
属性采用 names 库列表 linked,即不带 lib
前缀或 .so
后缀。
例如,您将使用:
cpp.libraryPaths: ["/home/r0ng/tools/myapp/libs/relic/lib"]
cpp.dynamicLibraries: ["relic"]
但是,由于您已经有了想要 link 的动态库的完整文件路径,因此您可以简单地传递完整文件路径而无需指定 cpp.libraryPaths
,就像这样:
cpp.dynamicLibraries: ["/home/r0ng/tools/myapp/libs/relic/lib/librelic.so"]
第二种方法是首选,因为它指定了要 link 的确切库,而不是依赖于可能不一定选择您期望的库类型的搜索路径(如果静态和动态版本存在)。
我承认应该更好地记录我们的 cpp.dynamicLibraries
和 cpp.staticLibraries
属性,以解释它们的预期用途。
关于references
,是的,您可以引用任何文件路径,而不考虑其文件系统位置。
关于 Depends
,该项目的 name
属性 指定要创建依赖项的产品或模块的名称。这样的产品或模块必须已经存在于您的项目树中,例如由于使用 qbsSearchPaths
或 references
属性而加载。