Qt qbs 项目设置与库未找到编译错误
Qt qbs project settings with library not found compile error
我正在做一个有几个级别的项目。就个人而言,我是 qbs 的新手,内部关于 qbs 的文档和示例并不多。
环境:
Qt5.6.1;Qt创建者4.01;乌班图16.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"...]
}
最后是我们库的 QB:
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 以使构建过程正常工作?
另一个问题是关于关键字"参考"。我可以引用项目中任何关卡中的其他 qbs 文件吗?它是如何工作的?我也得到了关于"依赖"的相同问题。
谢谢
荣
cpp.dynamicLibraries
和 cpp.staticLibraries
属性采用要链接的库名称列表,即没有lib
前缀或.so
后缀的库名称。
例如,您可以使用:
cpp.libraryPaths: ["/home/r0ng/tools/myapp/libs/relic/lib"]
cpp.dynamicLibraries: ["relic"]
但是,由于您已经拥有要链接的动态库的完整文件路径,因此您可以简单地传递完整文件路径,而无需指定cpp.libraryPaths
,如下所示:
cpp.dynamicLibraries: ["/home/r0ng/tools/myapp/libs/relic/lib/librelic.so"]
第二种方法是首选,因为它指定了要链接到的确切库,而不是依赖于搜索路径,搜索路径不一定会选择您期望的库类型(如果同时存在静态和动态版本)。
我承认,我们的cpp.dynamicLibraries
和cpp.staticLibraries
属性应该更好地记录下来,以解释它们的预期用途。
关于references
,是的,您可以引用任何文件路径,无论其文件系统位置如何。
关于Depends
,该项的 name
属性指定要创建依赖项的产品或模块的名称。此类产品或模块必须已存在于项目树中,例如,由于使用 qbsSearchPaths
或 references
属性而加载。
- std::is_base_of表示ctor编译错误
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- 如何修复sfml c++代码编译错误
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- vscode下的Arduino代码出现意外编译错误
- 第三方 API 中的编译错误 - Visual Studio
- std::cout输出int时出现编译错误
- 奇怪的代码抛出编译错误模板< J,int aSize=10> C2143:语法错误:在"<"之前缺少";"
- 提升图广度优先搜索前置编译错误
- C++ 中的编译错误:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 使用带有 ref 参数的成员函数创建线程时出现编译错误
- 我在C++中遇到了这个奇怪的编译错误
- 在C++中使用 Catch 测试框架编译错误"error: expected ';' at end of declaration list"
- 使用 std::enable_if 限制派生类的模板参数时出现编译错误
- 现代OpenGL和GLEW Libraray的编译错误
- C++ 编译错误:意外的类型名称"字符串":预期的表达式
- C ++程序编译错误,找不到/访问文件
- 使用直接大括号初始化时,C++ 编译错误"声明末尾的预期";"
- 为什么传递非静态成员函数会导致编译错误?