我有几个共享公共类的项目,因此我将更改项目布局以反映这些依赖关系,将其分解为作为静态库实现的组件。
现在,我创建了一个模块'io‘,它使用导出块导出其包含路径。模块依赖于“核心”。“核心”本身就是“应用程序”所依赖的,到目前为止没有什么特别之处。
导出项的文档说它的属性是传递的,但是我在编译包含在核心的应用程序时从编译器那里得到了几个错误。查看编译器语句,io导出的包含路径没有在包含路径中列出。在应用程序中将依赖项直接添加到io中时,一切都正常。
我是使用了导出/依赖对错误的,还是我的整体布局不好。
我更改了Qbs的应用程序和库示例,以反映我的布局以求澄清。
app
|- main.cpp
lib1
|- lib.cpp
lib2
|- lib.cpp
|- Test.h
=== app-and-lib.qbs
import qbs 1.0
Project {
references: [
"app/app.qbs",
"lib1/lib1.qbs",
"lib2/lib2.qbs"
]
}
=== app.qbs
import qbs 1.0
Product {
type: "application"
name : "app-and-lib-app"
files : [ "main.cpp" ]
Depends { name: "cpp" }
Depends { name: "lib1" }
}
=== lib1.qbs
import qbs 1.0
Product {
type: "staticlibrary"
name: "lib1"
files: [ "lib.cpp" ]
cpp.defines: ['CRUCIAL_DEFINE']
Depends { name: 'cpp' }
Depends { name: "lib2" }
}
=== lib2.qbs
import qbs 1.0
Product {
type: "staticlibrary"
name: "lib2"
files: [
"Test.h",
"lib.cpp",
]
cpp.defines: ['CRUCIAL_DEFINE']
Depends { name: 'cpp' }
Export {
Depends { name: "cpp" }
cpp.includePaths: "."
}
}
=== lib.cpp
#include <stdio.h>
#include "Test.h"
#ifndef CRUCIAL_DEFINE
# error CRUCIAL_DEFINE not defined
#endif
int bla()
{
puts("Hello World!");
return 2;
}
=== main.cpp
#include <stdio.h>
#include "Test.h" // Error cannot found Test.h
int bla();
int main()
{
Test t = new Test();
return bla();
}发布于 2016-02-03 19:59:47
通过IRC到Qbs Jira,并从开发人员那里得到了答案,即这是文档中的一个错误。要导出依赖项,必须导出它,因此lib1.qbs需要像这样进行扩展
Exports {
Depends { name: "lib2" }
}https://stackoverflow.com/questions/35131878
复制相似问题