Issue
I've compiled SFML and built the example project just fine, however when I moved onto my own project I'm getting linker errors. Here's the output of ndk-build.
$ ndk-build
[armeabi-v7a] Compile++ thumb: game <= main.cpp
[armeabi-v7a] Compile++ thumb: game <= Game.cpp
[armeabi-v7a] Compile++ thumb: game <= GameState.cpp
[armeabi-v7a] Compile++ thumb: game <= ResourceManager.cpp
[armeabi-v7a] Prebuilt : libsfml-graphics.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt : libsfml-audio.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt : libsfml-network.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt : libsfml-window.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt : libsfml-system.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] SharedLibrary : libgame.so
/Programming/Android/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /Programming/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libsfml-graphics.so
/Programming/Android/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /Programming/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libsfml-audio.so
/Programming/Android/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /Programming/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libsfml-network.so
/Programming/Android/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /Programming/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libsfml-window.so
/Programming/Android/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol '__aeabi_atexit' in /Programming/Android/NDK/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/libgnustl_static.a(atexit_arm.o) is referenced by DSO ./obj/local/armeabi-v7a/libsfml-system.so
jni/Game.cpp:14: error: undefined reference to 'sf::String::String(char const*, std::locale const&)'
jni/ResourceManager.cpp:69: error: undefined reference to 'sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'
jni/ResourceManager.cpp:83: error: undefined reference to 'sf::Font::loadFromFile(std::string const&)'
jni/ResourceManager.cpp:108: error: undefined reference to 'sf::SoundBuffer::loadFromFile(std::string const&)'
jni/ResourceManager.cpp:137: error: undefined reference to 'sf::SoundBuffer::loadFromFile(std::string const&)'
jni/ResourceManager.cpp:153: error: undefined reference to 'sf::SoundBuffer::loadFromFile(std::string const&)'
jni/ResourceManager.cpp:170: error: undefined reference to 'sf::Music::openFromFile(std::string const&)'
jni/ResourceManager.cpp:198: error: undefined reference to 'sf::Music::openFromFile(std::string const&)'
jni/ResourceManager.cpp:213: error: undefined reference to 'sf::Music::openFromFile(std::string const&)'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libgame.so] Error 1
I have no idea what all the "is referenced by DSO" errors are, but the undefined references make no sense. Why would I have undefined reference to functions when compiling the resourcemanager that I don't have when compiling say the game class which uses plenty of things from the same library?
My Application.mk file:
NDK_TOOLCHAIN_VERSION := 4.8
APP_PLATFORM := android-9
APP_STL := gnustl_static
APP_CPPFLAGS := -std=c++0x
APP_ABI := armeabi-v7a
My Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game
LOCAL_SRC_FILES := main.cpp Game.cpp GameState.cpp ResourceManager.cpp
LOCAL_SHARED_LIBRARIES := sfml-system
LOCAL_SHARED_LIBRARIES += sfml-window
LOCAL_SHARED_LIBRARIES += sfml-graphics
LOCAL_SHARED_LIBRARIES += sfml-audio
LOCAL_SHARED_LIBRARIES += sfml-network
LOCAL_WHOLE_STATIC_LIBRARIES := sfml-main
include $(BUILD_SHARED_LIBRARY)
$(call import-module,sfml)
EDIT: Linking the STL as shared instead of static fixes the first set of errors, still getting undefined references.
Solution
Turns out it was all in the Application.mk
NDK_TOOLCHAIN_VERSION := 4.8
APP_PLATFORM := android-9
APP_STL := c++_shared
APP_CPPFLAGS += -std=c++0x
APP_ABI := armeabi-v7a
APP_MODULES := sfml-activity game
Adding the modules and changing the stl to c++_shared fixed it.
Answered By - user2941616
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.