【问题标题】:Setup Google Test (gtest) with Eclipse on OS X在 OS X 上使用 Eclipse 设置 Google Test (gtest)
【发布时间】:2009-10-25 21:06:10
【问题描述】:

设置 Google Test 以在 Mac OS X 上的 Eclipse 下工作的过程是什么?我按照 README 中的说明从 XCode 编译和安装 gtest 作为框架。

现在我想在 Eclipse 中使用 gtest。目前,它编译良好,但在构建过程中失败。我想 Eclipse 不像 XCode 那样使用框架概念,并且需要不同的链接方法,但我不确定在构建期间应该链接到哪些文件。

g++ -L/usr/local/lib -L/usr/local/lib/libgtest.a -L/Library/Frameworks/gtest.framework -arch i386 -o "Raytracer"  ./test/sample_test.o  ./src/Raytracer.o   
Undefined symbols:
  "testing::Test::~Test()", referenced from:
      DemoTest_SANITY_Test::~DemoTest_SANITY_Test()in sample_test.o
      DemoTest_SANITY_Test::~DemoTest_SANITY_Test()in sample_test.o
  "testing::internal::AssertHelper::~AssertHelper()", referenced from:
      DemoTest_SANITY_Test::TestBody()      in sample_test.o
      DemoTest_SANITY_Test::TestBody()      in sample_test.o

【问题讨论】:

    标签: eclipse unit-testing macos googletest


    【解决方案1】:

    -L 开关只告诉 GCC 一个目录在哪里寻找库,实际的库必须用 -l 链接:

    g++ -L/usr/local/lib -lgtest ...
    

    【讨论】:

      猜你喜欢
      • 2023-03-05
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 2013-03-28
      • 1970-01-01
      • 2013-07-27
      • 2012-11-08
      相关资源
      最近更新 更多