0

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

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

项目的 GitHub 存储库

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"
    ]
}
4

2 回答 2

1

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

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

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

于 2017-11-28T02:05:26.150 回答
0

您确定这是来自链接器的全部错误消息吗?当然也提到了实际缺少的符号?

于 2017-11-26T12:51:25.277 回答