代码之家  ›  专栏  ›  技术社区  ›  BrainStone

只有在Travis CI上用gradle编译时,googletest符号才有“多重定义”

  •  0
  • BrainStone  · 技术社区  · 8 年前

    我在试着让特拉维斯的情报工作。
    所以我和gtest和gradle做了一些测试。只有一个测试文件可以完美地工作。不过,当我加上第二个,我得到吨 multiple definition 错误。它们只是最重要的象征。最奇怪的是,我无法在其他系统上复制。我用GCC7和GCC6尝试了我的本地Ubuntu机器,用VS 2015尝试了Debian和Windows。

    生成日志: https://travis-ci.org/fivunlm/cppstreams/jobs/420067374
    https://github.com/fivunlm/cppstreams/tree/0a89e8f01c9f868a2d690780b2afe159627bd81e
    生成文件: https://github.com/fivunlm/cppstreams/blob/0a89e8f01c9f868a2d690780b2afe159627bd81e/build.gradle

    编辑:

    主要问题是编译错误。不可恢复性,只会使它更难调试。

    我刚刚在我的Ubuntu虚拟机上重新创建了它。但这还是第一次。我可以试着直接调试它。我也能回答更深入的问题。

    1 回复  |  直到 8 年前
        1
  •  0
  •   BrainStone    8 年前

    事实证明,我没有正确编译gtest。罪魁祸首是: https://github.com/fivunlm/cppstreams/blob/0a89e8f01c9f868a2d690780b2afe159627bd81e/lib/build.gradle#L16-L17

    相反,应该是 include "src/gtest-all.cc"

    因此,如果您不确定gtest为什么会起作用,请确保只编译 src/gtest-all.cc .

    推荐文章