Linux下C ++:连接器的输出奇怪的错误 [英] Linux C++: Linker is outputting strange errors

查看:568
本文介绍了Linux下C ++:连接器的输出奇怪的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Alright, here is the output I get:

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

下面是我设法破译的错误:

Here's an error I managed to decipher:

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");

那么,什么似乎可笑我是第一个是罚款(第43行),但第二个不是。这是什么原因?

So, what seems funny to me is that the first new is fine (line 43), but the second one isn't. What could cause this?

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

与另一个问题

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

我不知道从哪里开始与其他的问题。

I have no idea where to begin with the other issues.

这是我的makefile,他们是一个巨大的烂摊子,因为我只是想获得它的工作。

These are my makefiles, They're a giant mess because I'm just trying to get it to work.

静态库:

# ====================================== #
#                                        #
#       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 $@

任何帮助将是AP preciated。

Any help would be appreciated.

推荐答案

看起来你是不是链接正确的C ++运行时库(可以是不同的那么的libstdc ++)。你应该尝试使用C ++编译器来驱动连接器而不是直接调用的连接器。

It looks like you are not linking the proper C++ runtime libraries (which can be different then libstdc++). You should try using the C++ compiler to drive the linker rather then invoking the linker directly.

如果您需要通过编译器将连接特定选项,你可以用-Wl:

If you need to pass linker specific options via the compiler, you can use -Wl:

arm-none-linux-gnueabi-g++ -Wl,--entry=main -Wl,-dynamic-linker=/system/bin/linker ...

这篇关于Linux下C ++:连接器的输出奇怪的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆