簡體   English   中英

與GCC的模糊鏈接錯誤,但與VC ++無關

[英]Obscure linking error with GCC, but not VC++

我正在制作一個旨在在android和Windows中使用的庫。 對於Windows,使用Visual Studio 2010可以編譯,鏈接和正常運行。

對於Android,我將ndk-build腳本與android-ndk-r7(使用gcc 4.4.3)一起使用。 我收到以下幾個鏈接器錯誤:

./obj/local/armeabi-v7a/libjonsengine.a(RenderManagerImpl.o):(.data.rel.ro._ZTI1
4IRenderManager[typeinfo for IRenderManager]+0x0): undefined reference to `vtabl
e for __cxxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(RenderManagerImpl.o):(.data.rel.ro._ZTI1
2IBaseManager[typeinfo for IBaseManager]+0x0): undefined reference to `vtable fo
r __cxxabiv1::__class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(RenderManagerImpl.o):(.data.rel.ro+0x34)
: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(LogManagerImpl.o):(.data.rel.ro._ZTI11IL
ogManager[typeinfo for ILogManager]+0x0): undefined reference to `vtable for __c
xxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(LogManagerImpl.o):(.data.rel.ro+0x38): u
ndefined reference to `vtable for __cxxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(MemoryManagerImpl.o):(.data.rel.ro._ZTI1
4IMemoryManager[typeinfo for IMemoryManager]+0x0): undefined reference to `vtabl
e for __cxxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(MemoryManagerImpl.o):(.data.rel.ro+0x40)
: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libandroidgame.so] Error 1

這是我的Android.mk:

LOCAL_PATH:= $(call my-dir)
TOP_PATH := $(LOCAL_PATH)

include $(CLEAR_VARS)
# Main engine
LOCAL_MODULE    := jonsengine
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/ \
                    $(LOCAL_PATH)/../include/Core/ \
                    $(LOCAL_PATH)/../interface/ \
                    $(LOCAL_PATH)/../include/Render/ \
                    $(LOCAL_PATH)/../include/Utils/ \
                    $(LOCAL_PATH)/../include/Memory/

# Core
LOCAL_SRC_FILES :=  ../src/Core/Engine.cpp

# Rendering
LOCAL_SRC_FILES +=  ../src/Render/RenderManagerImpl.cpp

# Utils
LOCAL_SRC_FILES +=  ../src/Utils/LogManagerImpl.cpp \
                    ../src/Utils/PortableTime.cpp

# Memory
LOCAL_SRC_FILES +=  ../src/Memory/MemoryManagerImpl.cpp \
                    ../src/Memory/MemoryPool.cpp \
                    ../src/Memory/dlmalloc.c

LOCAL_CFLAGS := -DSTRUCT_MALLINFO_DECLARED
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
LOCAL_LDLIBS    := -lGLESv2 -llog

include $(BUILD_STATIC_LIBRARY)



# Testing library
include $(CLEAR_VARS)

LOCAL_MODULE    := jonsenginetests
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../Tests/ \
                    $(LOCAL_PATH)/../Tests/Memory/ \
                    $(LOCAL_PATH)/../Tests/Core/

LOCAL_SRC_FILES :=  ../Tests/TestManager.cpp \
                    ../Tests/Memory/MemoryManagerTest.cpp \
                    ../Tests/TestClass1.cpp

LOCAL_CFLAGS :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
LOCAL_STATIC_LIBRARIES := jonsengine
LOCAL_LDLIBS    :=-llog

include $(BUILD_STATIC_LIBRARY)

我無法弄清楚該錯誤的含義或原因。 任何人都可以對此有所了解嗎? 正如我提到的,它在VC ++上可以正常工作。

編輯2

更新了錯誤日志。 這有什么幫助嗎?

例如,當我使用“ nm RenderManagerImpl.o”時,將獲得“ V”符號和“ _ZTI4IRenderManager”的“ 00000000”地址。

EDIT3 :看來如果我將jonsenginetests做成一個共享庫而不是靜態庫,它將進行編譯。 這意味着什么?

謝謝

這只是一個猜測,但類名聽起來可能與RTTI有關,在Android NDK中默認禁用該類。

假設我是對的,您可以通過將以下內容添加到Android.mk文件中來為您的應用程序啟用RTTI:

LOCAL_CPP_FEATURES := rtti

有關更多信息,建議docs\\CPLUSPLUS-SUPPORT.html在android NDK中的docs\\ANDROID-MK.htmldocs\\CPLUSPLUS-SUPPORT.htmldocs\\CPLUSPLUS-SUPPORT.html

也可能是您使用的是android NDK不支持的部分標准庫。 它的默認支持是相當有限的。 您可以通過在Application.mk提供APP_STL來更改其使用的APP_STL 例如:

APP_STL := gnustl_static

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM