2

好的,这是我得到的输出:

arm-none-linux-gnueabi-ld --entry=main -dynamic-linker=/system/bin/linker -rpath-link=/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -nostdlib -lstdc++ -lm -lGLESv1_CM -rpath=/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -rpath=../../YoghurtGum/lib/Android -L./lib/Android intermediate/Alien.o intermediate/Bullet.o intermediate/Game.o intermediate/Player.o ../../YoghurtGum/bin/YoghurtGum.a -o bin/Galaxians.android
intermediate/Game.o: In function `Galaxians::Init()':
/media/YoghurtGum/Tests/Galaxians/src/Game.cpp:45: undefined reference to `__cxa_end_cleanup'
/media/YoghurtGum/Tests/Galaxians/src/Game.cpp:44: undefined reference to `__cxa_end_cleanup'
intermediate/Game.o:(.ARM.extab+0x18): undefined reference to `__gxx_personality_v0'
intermediate/Game.o: In function `Player::Update()':
/media/YoghurtGum/Tests/Galaxians/src/Player.h:41: undefined reference to `__cxa_end_cleanup'
intermediate/Game.o:(.ARM.extab.text._ZN6Player6UpdateEv[_ZN6Player6UpdateEv]+0x0): undefined reference to `__gxx_personality_v0'
intermediate/Game.o:(.rodata._ZTIN10YoghurtGum4GameE[_ZTIN10YoghurtGum4GameE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
intermediate/Game.o:(.rodata._ZTI6Player[_ZTI6Player]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
intermediate/Game.o:(.rodata._ZTIN10YoghurtGum6EntityE[_ZTIN10YoghurtGum6EntityE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
intermediate/Game.o:(.rodata._ZTIN10YoghurtGum6ObjectE[_ZTIN10YoghurtGum6ObjectE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
intermediate/Game.o:(.rodata._ZTI6Bullet[_ZTI6Bullet]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
intermediate/Game.o:(.rodata._ZTI5Alien[_ZTI5Alien]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
intermediate/Game.o:(.rodata+0x20): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../YoghurtGum/bin/YoghurtGum.a(Sprite.o):(.rodata._ZTIN10YoghurtGum16SpriteDataOpenGLE[_ZTIN10YoghurtGum16SpriteDataOpenGLE]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
../../YoghurtGum/bin/YoghurtGum.a(Sprite.o):(.rodata._ZTIN10YoghurtGum10SpriteDataE[_ZTIN10YoghurtGum10SpriteDataE]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
make: *** [bin/Galaxians.android] Fout 1

这是我设法破译的一个错误:

intermediate/Game.o: In function `Galaxians::Init()':
/media/YoghurtGum/Tests/Galaxians/src/Game.cpp:45: undefined reference to `__cxa_end_cleanup'
/media/YoghurtGum/Tests/Galaxians/src/Game.cpp:44: undefined reference to `__cxa_end_cleanup'

这是第 43 到 45 行:

Assets::AddSprite(new Sprite("media\\ViperMarkII.bmp"),     "ship");
Assets::AddSprite(new Sprite("media\\alien.bmp"),           "alien");
Assets::AddSprite(new Sprite("media\\bat_ball.bmp"),        "bullet");

所以,我觉得有趣的是第一个new很好(第 43 行),但第二个不是。什么可能导致这种情况?

intermediate/Game.o: In function `Player::Update()':
/media/YoghurtGum/Tests/Galaxians/src/Player.h:41: undefined reference to `__cxa_end_cleanup'

另一个问题new

Engine::game->scene_current->AddObject(new Bullet(m_X + 10, m_Y));

我不知道从哪里开始处理其他问题。

这些是我的makefile,它们是一团糟,因为我只是想让它工作。

静态库:

# ====================================== #
#                                        #
#       YoghurtGum static library        #
#                                        #
# ====================================== #

include ../YoghurtGum.mk

PROGS = bin/YoghurtGum.a
SOURCES = $(wildcard src/*.cpp)

#$(YG_PATH_LIB)/libGLESv1_CM.so \
#$(YG_PATH_LIB)/libEGL.so \

YG_LINK_OPTIONS = -shared
YG_LIBRARIES = \
  $(YG_PATH_LIB)/libc.a \
  $(YG_PATH_LIB)/libc.so \
  $(YG_PATH_LIB)/libstdc++.a \
  $(YG_PATH_LIB)/libstdc++.so \
  $(YG_PATH_LIB)/libm.a \
  $(YG_PATH_LIB)/libm.so \
  $(YG_PATH_LIB)/libui.so \
  $(YG_PATH_LIB)/liblog.so \
  $(YG_PATH_LIB)/libGLESv2.so \
  $(YG_PATH_LIB)/libcutils.so \

YG_OBJECTS = $(patsubst src/%.cpp, $(YG_INT)/%.o, $(SOURCES))

YG_NDK_PATH_LIB = /home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib

all: $(PROGS)

rebuild: clean $(PROGS)

# remove all .o objects from intermediate and all .android objects from bin
clean:
    rm -f $(YG_INT)/*.o $(YG_BIN)/*.a

copy:
    acpy ../$(PROGS)   

$(PROGS): $(YG_OBJECTS)
    $(YG_ARCHIVER) -vq $(PROGS) $(YG_NDK_PATH_LIB)/crtbegin_static.o $(YG_NDK_PATH_LIB)/crtend_android.o $^ && \
  $(YG_ARCHIVER) -vr $(PROGS) $(YG_LIBRARIES) 

$(YG_OBJECTS): $(YG_INT)/%.o : $(YG_SRC)/%.cpp
    $(YG_COMPILER) $(YG_FLAGS) -I $(GLES_INCLUDES) -c $< -o $@

测试游戏项目:

# ====================================== #
#                                        #
#               Galaxians                #
#                                        #
# ====================================== #

include ../../YoghurtGum.mk

PROGS = bin/Galaxians.android

YG_COMPILER = arm-none-linux-gnueabi-g++
YG_LINKER = arm-none-linux-gnueabi-ld
YG_PATH_LIB = ./lib/Android
YG_LIBRARIES = ../../YoghurtGum/bin/YoghurtGum.a

YG_PROGS = bin/Galaxians.android
GLES_INCLUDES = ../../YoghurtGum/src

ANDROID_NDK_ROOT = /home/oem/android-ndk-r3
NDK_PLATFORM_VER = 5
YG_NDK_PATH_LIB = $(ANDROID_NDK_ROOT)/build/platforms/android-$(NDK_PLATFORM_VER)/arch-arm/usr/lib

YG_LIBS = -nostdlib -lstdc++ -lm -lGLESv1_CM

#YG_COMPILE_OPTIONS = -g -rdynamic -Wall -Werror -O2 -w
YG_COMPILE_OPTIONS = -g -Wall -Werror -O2 -w
YG_LINK_OPTIONS = --entry=main -dynamic-linker=/system/bin/linker -rpath-link=$(YG_NDK_PATH_LIB) -L$(YG_NDK_PATH_LIB) $(YG_LIBS)

SOURCES = $(wildcard src/*.cpp)
YG_OBJECTS = $(patsubst src/%.cpp, intermediate/%.o, $(SOURCES))

all: $(PROGS)

rebuild: clean $(PROGS)

clean:
    rm -f intermediate/*.o bin/*.android

$(PROGS): $(YG_OBJECTS)
    $(YG_LINKER) $(YG_LINK_OPTIONS) -rpath=$(YG_NDK_PATH_LIB) -rpath=../../YoghurtGum/lib/Android -L$(YG_PATH_LIB) $^ $(YG_LIBRARIES) -o $@

$(YG_OBJECTS): intermediate/%.o : src/%.cpp
    $(YG_COMPILER) $(YG_COMPILE_OPTIONS) -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c $< -o $@

任何帮助,将不胜感激。

4

2 回答 2

3

看起来您没有链接正确的 C++ 运行时库(可能与 libstdc++ 不同)。您应该尝试使用 C++ 编译器来驱动链接器,而不是直接调用链接器。

如果需要通过编译器传递链接器特定选项,可以使用 -Wl:

arm-none-linux-gnueabi-g++ -Wl,--entry=main -Wl,-dynamic-linker=/system/bin/linker ...
于 2010-04-19T05:23:00.430 回答
1

我刚刚遇到了非常相似的问题,我得到了同事的答案。

   LOCAL_CFLAGS += -frtti

它使链接器将“运行时类型信息”包含到您可能在代码中使用的二进制文件中。

于 2012-02-08T15:32:49.937 回答