QT 5.5.1 .so Bibliothek mit Android

Ich habe die mit openssl kompilierte Bibliothek für Armeabi- und x86-Android-Plattformen von @ heruntergeladeHie und versuchte es in die .pro-Datei zu laden:

INCLUDEPATH += C:\Temp\openssl\OpenSSL-for-Android-Prebuilt\openssl-1.0.2\include\
LIBS += -LC:\Temp\openssl\OpenSSL-for-Android-Prebuilt\openssl-1.0.2\armeabi-v7a\lib \
-llibssl
-llibcrypto

Ich habe es auch mit @ versuc-llibssl.so -llibcrypto.so und-llibssl.a -llibcrypto.a aber dieser Fehler tritt auf:

collect2.exe: -1: Fehler: Fehler: ld hat 1 Exit-Status zurückgegeben

Der Code ist eine einfache Verwendung von SHA1 und wird unter MSVC 12.0 mit .lib-Bibliotheken erfolgreich ausgeführt:

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QMessageBox"
#include <openssl/sha.h>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    const unsigned char ibuf[] = "compute sha1";
    const char ibuf1[] = "compute sha1";
    unsigned char obuf[20];

    SHA1(ibuf, strlen(ibuf1), obuf);

    int i;
    for (i = 0; i < 20; i++) {
        printf("%02x ", obuf[i]);
    }
    printf("\n");
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    QMessageBox::about(this,tr("Test"),tr("Hellow man!!!"));
}

Natürlich habe ich Foren gelesen, also hier ist das vollständige Protokoll:

C:\Users\niki\Downloads\android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi-g++ --sysroot=C:\Users\niki\Downloads\android-ndk-r10e/platforms/android-9/arch-arm/ -Wl,-soname,libtestAndroid.so -Wl,--no-undefined -Wl,-z,noexecstack -shared -o libtestAndroid.so main.obj mainwindow.obj moc_mainwindow.obj   -LC:\Users\niki\Downloads\android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi -LC:\Users\niki\Downloads\android-ndk-r10e/platforms/android-9/arch-arm//usr/lib -LC:/Qt/5.5/android_armv5/lib -lQt5Widgets -Lc:\utils\android\ndk/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi -Lc:\utils\android\ndk/platforms/android-9/arch-arm//usr/lib -lQt5Gui -lQt5Core -lGLESv2 -lgnustl_shared -llog -lz -lm -ldl -lc -lgcc
mainwindow.obj:mainwindow.cpp:function MainWindow::MainWindow(QWidget*): error: undefined reference to 'SHA1'
collect2.exe: error: ld returned 1 exit status
makefile:83: recipe for target 'libtestAndroid.so' failed
mingw32-make: *** [libtestAndroid.so] Error 1
10:47:05: The process "C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project testAndroid (kit: Android for armeabi (GCC 4.9, Qt 5.5.1))
When executing step "Make"

Es scheint, dass SHA1 das Problem ist. In sha.h ist definiert

#ifdef  __cplusplus
extern "C" {
#endif
#ifdef  __cplusplus
}
#endif

so das ist nicht das problem. Es gibt eine Android.mk-Datei. Was ist zu tun? Soll ich es irgendwie in die .pro-Datei laden? Ich wollte nur die Verwendung von openssl in Android ausprobieren, bevor ich es kompiliere, um sicherzugehen, dass es möglich ist zu arbeiten (da das Kompilieren Zeit in Anspruch nimmt und unter Linux erfolgen muss).

Antworten auf die Frage(2)

Ihre Antwort auf die Frage