简体   繁体   English

将CrystaX与Qt结合使用以构建android应用程序:java.lang.UnsatisfiedLinkError

[英]Using CrystaX with Qt to build android application: java.lang.UnsatisfiedLinkError

I am trying to build Qt application for android using Qt Creator . 我正在尝试使用Qt Creator为Android构建Qt application I use CrystaX NDK for android instead of goolge's one because I need to use boost libraries in my project, and, as CrystaX's official site says, it is comes with it. 我将CrystaX NDK用于android而不是goolge,因为我需要在项目中使用boost libraries ,而且正如CrystaX的官方网站所说,它是附带的。

I am using following versions of tools: 我正在使用以下版本的工具:

  • Qt Creator 3.4.2 Qt Creator 3.4.2
  • Qt 5.5.0 Qt 5.5.0
  • CrystaX NDK 10.2.1 CrystaX NDK 10.2.1

At first, I had to manually add libraries and headers paths in my .pro file, because it hasn't been found automatically. 首先,我必须在.pro文件中手动添加库和头文件路径,因为尚未自动找到它。 There was compiler error: can't locate libcrystax , there was some errors in source files about including boost headers . 发生编译器错误: can't locate libcrystax ,源文件中存在一些有关包含boost headers错误。 I've added following lines in my project file: 我在项目文件中添加了以下几行:

android {
    INCLUDEPATH +=  $$NDK_ROOT/sources/crystax/include \
                    $$NDK_ROOT/sources/boost/1.58.0/include \
                    $$PWD/ssl
    LIBS += -L"$$PWD/ssl" -lssl -lcrypto
    LIBS += -L"$$NDK_ROOT/sources/crystax/libs/$$ANDROID_TARGET_ARCH"
    ANDROID_EXTRA_LIBS = $$NDK_ROOT/sources/crystax/libs/$$ANDROID_TARGET_ARCH/libcrystax.so
    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
}

After rebuilding again, I've got an error ( runtime error ) that says libgnustl_shared requires libcrystax, but libcrystax is not loaded or something similar. 再次重建后,出现一个错误( runtime error ),提示libgnustl_shared requires libcrystax, but libcrystax is not loaded或类似的东西。

After searching the internet, I've found that it's happening because one library that requires another, is loading before it, and that second library, is not being searched for, at application directory, only in system paths. 搜索互联网之后,我发现它正在发生,因为一个需要另一个的库正在加载,而另一个库则不在应用程序目录中的系统路径中被搜索。

I've found a workaround - to load required library manually. 我找到了一种解决方法-手动加载所需的库。 I copied default QtActivity.java into my project directory ( android/src/.../QtActivity.java ) to replace default one and added following code: 我将默认的QtActivity.java复制到我的项目目录( android/src/.../QtActivity.java )中,以替换默认的android/src/.../QtActivity.java ,并添加了以下代码:

static {
    System.loadLibrary( "crystax" );
}

After that I am not getting that error, but now I'm stuck with another one: 之后,我没有收到该错误,但是现在我陷入了另一个错误:

java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]: 37 cannot locate '__aeabi_ldiv0'...

Is it possible to use Qt + CrystaX NDK for build android app? 是否可以使用Qt + CrystaX NDK构建Android应用程序? Am I doing it wrong way? 我做错了吗? Please, explain how to do it properly, if I've mistaken or if I misunderstood whole concept. 请解释一下如果我误解或误解了整个概念的方法。 Any help is appreciated. 任何帮助表示赞赏。

This happens because you haven't linked with libgcc.a . 发生这种情况是因为您尚未链接libgcc.a I don't know how exactly your build system works (well, Qt's one), but generally, adding libgcc.a to the list of additional libraries should help: 我不知道您的构建系统是如何工作的(嗯,是Qt的),但是通常,将libgcc.a添加到其他库列表中应该会有所帮助:

ANDROID_EXTRA_LIBS = $$NDK_ROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.9/libgcc.a

This line specify arm variant of libgcc.a ; 该行指定libgcc.a arm变体; obviously, you should use proper one depending on ANDROID_TARGET_ARCH value. 显然,您应该根据ANDROID_TARGET_ARCH值使用适当的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM