./obj/local/armeabI/ObJs-deBUG/ndkfoo_unittest/FilteredPriorityQueue_test.o:FilteredPriorityQueue_test.cpp:function typeinfo for mashbot::FilteredPriorityQueueTest_ShouldRetrIEvetop_Test: error: undefined reference to 'typeinfo for testing::Test'collect2: error: ld returned 1 exit statusmake: *** [obj/local/armeabi/ndkfoo_unittest] Error 1
这是我目前所知道的:
> :: testing :: Test是由test()宏自动子类化的Google Test类.
>当链接器无法找到虚拟方法的定义时,通常会发生对typeinfo的错误定义.
> could be caused by compiling google test with different flags,但不应该是这种情况,因为我使用的是静态谷歌测试库,两个模块之间的标志是相同的.
我错过了什么?或者我在哪里可以看到下一个?谢谢!
更新:如果我从ndkfoo_unittest模块中删除SHARED_liBRARIES,CPP_FLAGS和LDliBS,我可以构建一个不依赖于Boost或AndroID原生APIs的简单Google Test.
构建命令:
ndk-build SHELL=/bin/bash NDK_DEBUG=1
FilteredPriorityQueue_test.cpp:
#include "gtest/gtest.h"// FilteredPriorityQueue is a header-only file with no virtual methods.#include "FilteredPriorityQueue.h"// So is Comparator.#include "Comparator.h"struct Maskedobject { int mMask; Maskedobject(int mask) : mMask(mask) { } int getMask() const { return mMask; } bool operator<(const Maskedobject& rhs) const { return this->mMask < rhs.mMask; }};typedefFilteredPriorityQueue<int,Maskedobject,Comparator<Maskedobject> > TestQueue;TEST(FilteredPriorityQueueTest,ShouldRetrIEvetop) { Comparator<Maskedobject> comparator(Comparator<Maskedobject>::LESS); TestQueue q(comparator); q.push(1,Maskedobject(1)); q.push(2,Maskedobject(2)); q.push(4,Maskedobject(4)); EXPECT_EQ( 1,q.top().getMask() );}
AndroID.mk:
# ndkfoo module#-------------------------LOCAL_MODulE := ndkfooLOCAL_CPPFLAGS := -frtti -pthread -fexceptions -std=c++11LOCAL_LDliBS += -lOpenSLES -llog -landroIDLOCAL_C_INCLUDES += $(libmASHBOT_ROOT)/includeLOCAL_C_INCLUDES += $(BOOST_INCLUDE_PARENT)LOCAL_SHARED_liBRARIES += mashbot \ gnustl_shared \ boost_thread-gcc-mt-1_53 \ boost_system-gcc-mt-1_53 \ $(BOOST_liB)LOCAL_SRC_fileS := ndkfoo.cpp \ #...more files...include $(BUILD_SHARED_liBRARY)# ndkfoo tests module#-------------------------include $(CLEAR_VARS)LOCAL_MODulE := ndkfoo_unittestLOCAL_CPPFLAGS := -frtti -pthread -fexceptions -std=c++11LOCAL_C_INCLUDES += $(BOOST_INCLUDE_PARENT)LOCAL_STATIC_liBRARIES := Googletest_mainLOCAL_SHARED_liBRARIES += ndkfoo \ gnustl_shared \ $(BOOST_liB)LOCAL_SRC_fileS := FilteredPriorityQueue_test.cppinclude $(BUILD_EXECUtable)# this imports $NDK/sources/third_party/Googletest/AndroID.mk $(call import-module,third_party/Googletest)解决方法 我相信这是因为你没有启用RTTI.尝试添加
APP_CPPFLAGS += -fexceptionsAPP_CPPFLAGS += -frtti
到Application.mk.这解决了我.根据文档,您应该能够指定
LOCAL_CPP_FEATURES := rtti exceptions
在AndroID.mk,但这对我使用NDK r10c不起作用.另请注意,启用RTTI不是必需的,但使用RTTI的代码必须链接到支持RTTI的标准库,而带RTTI的库也支持异常.
总结以上是内存溢出为你收集整理的在Android NDK上使用Google Test测试’typeinfo for testing :: Test’的未定义引用全部内容,希望文章能够帮你解决在Android NDK上使用Google Test测试’typeinfo for testing :: Test’的未定义引用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)