在 OS X 上使用 Eclipse 设置 Google 测试 (gtest)

发布于 2024-08-08 16:55:52 字数 784 浏览 5 评论 0原文

在 Mac OS X 上的 Eclipse 下设置 Google Test 的过程是什么?我按照 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

What is the procedure to setup Google Test to work under Eclipse on Mac OS X? I followed the instruction in README to compile and install gtest as framework from XCode.

Now I want to use gtest with Eclipse. Currently, it compiles fine but fails during build. I suppose Eclipse does not use framework concept as XCode does and need a different linking approach, but I'm not sure which files should I link to during build.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好久不见√ 2024-08-15 16:55:52

-L 开关仅告诉 GCC 在哪里查找库的目录,实际的库必须与 -l 链接:

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

The -L switch only tells GCC a directory where to look for libraries, the actual library must be linked with -l:

g++ -L/usr/local/lib -lgtest ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文