0

I'm trying to compile an application using C++11 and OpenGL ES for Android using NativeActivity. I'm using

APP_STL := gnustl_shared

and everything compiles just fine. But when running my app I get:

dlopen(libjngl-test.so): Cannot load library: soinfo_relocate(linker.cpp:976): cannot locate symbol "_ZSt11_Hash_bytesPKvjj" referenced by "libjngl-test.so"...

jngl-test ist my activity. This is how my loading code looks like:

#include <android/native_activity.h>
#include <android/log.h>
#include <dlfcn.h>
#include <errno.h>
#include <stdexcept>

void* load_lib(const std::string& l) {
    auto handle = dlopen(std::string("/data/data/com.bixense.jngl_test/lib/" + l).c_str(),
                         RTLD_NOW | RTLD_GLOBAL);
    if (!handle) {
        throw std::runtime_error(std::string("dlopen(") + l + "): " + dlerror());
    }
    __android_log_print(ANDROID_LOG_INFO, "bootstrap", "Loaded %s", l.c_str());
    return handle;
}

void ANativeActivity_onCreate(ANativeActivity* app, void* ud, size_t udsize) {
    try {
        load_lib("libogg.so");
        load_lib("libvorbis.so");
        auto main = reinterpret_cast<void (*)(ANativeActivity*, void*, size_t)>(
            dlsym(load_lib("libjngl-test.so"), "ANativeActivity_onCreate")
        );
        if (!main) {
            throw std::runtime_error("undefined symbol ANativeActivity_onCreate");
        }
        main(app, ud, udsize);
    } catch(std::exception& e) {
        __android_log_print(ANDROID_LOG_ERROR, "bootstrap", "%s", e.what());
        ANativeActivity_finish(app);
    }
}

Does anybody have an idea what I'm doing wrong? Where could _ZSt11_Hash_bytesPKvjj come from?

jhasse
  • 2,379
  • 1
  • 30
  • 40
  • 1
    Translation from `c++filt`: `std::_Hash_bytes(void const*, unsigned int, unsigned int)`. Part of libstdc++? https://github.com/mirrors/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/hash_bytes.cc – fadden Nov 11 '13 at 22:50
  • Thanks! I wonder why it can't locate that symbol though. – jhasse Nov 13 '13 at 11:24
  • Which libraries are you linking in your makefile? – fadden Nov 13 '13 at 15:30
  • The following: log android EGL GLESv1_CM freetype png z ogg vorbis openal And my own static library called jngl. – jhasse Nov 14 '13 at 17:05

0 Answers0