gpt4 book ai didi

c++ - MacOS 上的 Qbs 静态库

转载 作者:行者123 更新时间:2023-11-28 04:54:23 26 4
gpt4 key购买 nike

我尝试将现有项目从 qmake 移动到 qbs,到目前为止一切正常,但我无法链接到 MacOS 上该项目中的 google test 静态库,而在 Windows 上它工作正常。

在 MacOS 上我得到 :-1: error: symbol(s) not found for architecture x86_64

GitHub repo of the project

googletest.qbs:

import qbs

StaticLibrary {
name: "GoogleTest"
files: [
"googletest/googletest/src/gtest-all.cc",
"googletest/googlemock/src/gmock-all.cc"
]

cpp.includePaths: [
"googletest/googletest/include",
"googletest/googlemock/include",
"googletest/googletest",
"googletest/googlemock"
]

Depends { name: "cpp" }
Export {
Depends { name: "cpp" }
cpp.includePaths: [
"googletest/googletest/include",
"googletest/googlemock/include"
]
}
}

测试.qbs:

import qbs

QtApplication {
name: "Test"
targetName: "Test"

Depends { name: "Qt"; submodules: ["core","testlib"]; versionAtLeast: "5.6" }
Depends { name: "GoogleTest"}

cpp.cxxLanguageVersion: "c++11"
consoleApplication: true

files: [
"QtTypePrinters.h",
"main.cpp",
"QStringTest.cpp"
]
}

最佳答案

您需要在静态库产品中设置以下属性:

cpp.cxxLanguageVersion: "c++11"
cpp.cxxStandardLibrary: "libc++"
cpp.minimumMacosVersion: "10.7" // or higher

默认情况下,Qbs 只是让编译器推断默认值。 gtest 恰好需要 C++11 和 libc++,而后者仅在 macOS 10.7 及更高版本上受 Apple 支持。

关于c++ - MacOS 上的 Qbs 静态库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47496052/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com