如何通过QBS附加PostgreSQL C库?

时间:2016-11-21 14:10:20

标签: c++ postgresql libpq qbs

我有一个项目应该使用postgresql c-library(libpq)并配置项目。我如何配置QBS模块将所有必需的头文件和库导入到项目中?

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:

import qbs 1.0

Product {
   name: "PostgresqlConnector"
   type: "dynamiclibrary"

   Depends {name:"cpp"}
   Depends { name: "Qt.core" }
   Depends { name: "UniversalDataObjects" }

   property string rootPath: "/Users/romanvolkov/Desktop/postgresql-9.6.0/src/"
   cpp.includePaths: [rootPath + "/include/",
       rootPath + "/interfaces/ecpg/pgtypeslib/",
       rootPath + "interfaces/libpq/"]
   cpp.dynamicLibraries: [rootPath + "interfaces/libpq/" + "libpq.dylib"]

   files: [
       "postgresqlconnectioninfo.cpp",
       "postgresqlconnectioninfo.h",
   ]
}

你只需导入cpp依赖项, 使用libpg srcs,pgtypes标头和包含文件设置cpp.includePaths 设置名为dynamic lib的cpp.dynamicLibraries(默认库通过make编译为动态lib)