在 OS X 上使用 Eclipse 设置 Google 测试 (gtest)
在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
-L 开关仅告诉 GCC 在哪里查找库的目录,实际的库必须与 -l 链接:
The -L switch only tells GCC a directory where to look for libraries, the actual library must be linked with -l: