Search code examples
androidc++qtopensslcrypto++

QT Windows to Android necessity project changes


I have a project which uses Crypto++, OpenSSL and QT 5.5.1 framework. Its for x86 Qindows with MSVC 12.0 compiler.

Now I want to run this project on android virtual device Nexus S. I have installed JDK, SDK, NDK, runed Nexus S for armebi architecture, GCC 4.9 compiler and QT 5.5.1 for Android armv5.

The Android Virtual Device (AVD) starts and run some examples successfully, but my program is not running in the same way. Here is .pro file:

#-------------------------------------------------
#
# Project created by QtCreator 2015-11-20T12:41:07
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = EPsimple
TEMPLATE = app

SOURCES += main.cpp\
    mainwindow.cpp \
    statusdialog.cpp \
    model.cpp \
    logindialog.cpp \
    threadedcontroller.cpp

HEADERS  += mainwindow.h \
    statusdialog.h \
    model.h \
    logindialog.h \
    threadedcontroller.h

FORMS    += mainwindow.ui \
    statusdialog.ui \
    logindialog.ui

INCLUDEPATH += C:\OpenSSL-Win32\include
INCLUDEPATH += C:\Users\niki\Downloads\cryptopp563rc5-1

debug{
LIBS += -LC:\Users\niki\Downloads\cryptopp563rc5-1\Win32\Output\Release \
-lcryptlib
LIBS += -LC:\OpenSSL-Win32\lib\VC \
-llibeay32MDd
}

release{
LIBS += -LC:\Users\niki\Downloads\cryptopp563rc5-1\Win32\Output\Debug \
-lcryptlib
LIBS += -LC:\OpenSSL-Win32\lib\VC \
-llibeay32MD
}

QMAKE_CXXFLAGS_RELEASE += /MD
QMAKE_CXXFLAGS_DEBUG += /MDd
#QMAKE_LFLAGS += /STACK:32000000
#QMAKE_LFLAGS += /HEAP:32000000

Following error occurs:

:-1: error: error: /MD: No such file or directory

Is it necessary to compile cryptopp and openssl libraries for GCC 4.9 compiler and what will happen with /MD and /MT options (are they still available for android)? The whole code can be seen from here (second version).


Solution

  • Is it necessary to compile cryptopp and openssl libraries for GCC 4.9 compiler

    Yes. You can set-up the QT project to compile Crypto++ under the environment. Or, see Android (Command Line) on the Crypto++ wiki.


    QMAKE_CXXFLAGS_RELEASE += /MD
    QMAKE_CXXFLAGS_DEBUG += /MDd
    

    ...
    :-1: error: error: /MD: No such file or directory

    This is a Windows compiler linker switch. /MD specifies linking with the Multithreaded DLL version of the runtime library. You should not be using it for an Android project.

    It sounds like you need to add a new configuration to your QT project. Your best bet is to probably create a new QT project and keep them separate.

    I believe Wei Dai's GitHub has a pull request for an Android.mk. We want to incorporate it into the library eventually. See Add Android.mk to build using android NDK. (Wei is the author of Crypto++).