建设SMTP客户端的Qt为针对Android目标 [英] Building SMTP client for Qt for Android target

查看:327
本文介绍了建设SMTP客户端的Qt为针对Android目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 SMTP客户端项目创建一个库文件(.dll文件)在Windows上。一切工作正常和电子邮件发送成功。

我想端口我的Qt项目,Android和由于Android是一个不同的架构,我需要用Android的ARMv7的工具包来构建库。

我试试这个,但我得到的错误:


  

内部错误:未知的Andr​​oid部署JSON文件的位置。
  错误而构建/部署项目SMTPEmail(试剂盒:Android的对armeabi-V7A(GCC 4.9,Qt的5.4.2))
  当执行步骤构建Android APK


我怀疑有件事我必须添加/从项目文件中删除。我看到有一个的win32:CONFIG + = DLL,但没有其他平台类似

该文件的.pro看起来是这样的:

\r
\r

#---------------- ---------------------------------\r
#\r
由QtCreator 2011-08-11T20创建#项目:59:25\r
#\r
#-------------------------------------------------\r
\r
QT + =核心网络\r
\r
TARGET = SMTPEmail\r
\r
#作为构建的应用程序\r
#TEMPLATE =应用\r
\r
#打造为一个库\r
模板= LIB\r
DEFINES + = SMTP_BUILD\r
的win32:CONFIG + = DLL\r
\r
QMAKE_CXXFLAGS + = -fPIC\r
\r
SOURCES + = \\\r
    SRC / emailaddress.cpp \\\r
    SRC / mimeattachment.cpp \\\r
    SRC / mimefile.cpp \\\r
    SRC / mimehtml.cpp \\\r
    SRC / mimeinlinefile.cpp \\\r
    SRC / mimemessage.cpp \\\r
    SRC / mimepart.cpp \\\r
    SRC / mimetext.cpp \\\r
    SRC / smtpclient.cpp \\\r
    SRC / quotedprintable.cpp \\\r
    SRC / mimemultipart.cpp \\\r
    SRC / mimecontentformatter.cpp \\\r
\r
HEADERS + = \\\r
    SRC / emailaddress.h \\\r
    SRC / mimeattachment.h \\\r
    SRC / mimefile.h \\\r
    SRC / mimehtml.h \\\r
    SRC / mimeinlinefile.h \\\r
    SRC / mimemessage.h \\\r
    SRC / mimepart.h \\\r
    SRC / mimetext.h \\\r
    SRC / smtpclient.h \\\r
    SRC / SmtpMime \\\r
    SRC / quotedprintable.h \\\r
    SRC / mimemultipart.h \\\r
    SRC / mimecontentformatter.h \\\r
    SRC / smtpexports.h\r
\r
OTHER_FILES + = \\\r
    执照 \\\r
    README.md\r
\r
表格+ =

\r

\r
\r


解决方案

由于在OP评论,我有同样的问题,可以通过简单地添加应用程序到我的项目解决它。

我最初的项目是一个简单的.pro文件打靶库(TinyXML的)。有了Qt 5.2.1(Qt Creator的3.0.1),我是能够编译为Android库(创建一个.so文件)。有了Qt 5.5.0(Qt Creator的3.4.0),我有同样的错误消息,报道中的OP。

下面是我的解决方案:

我创造了另一个.pro文件打靶的虚拟程序:

mockup_app.pro:

  TARGET = mockup_app
SOURCES + = main.cpp中
模板=应用

main.cpp中:

  //实际上从未编译
诠释的main()
{
    返回0;
}

toplevel.pro:

 模板=子目录
SUBDIRS + = tinyxml.pro
SUBDIRS + = mockup_app.pro

然后,打开toplevel.pro。转到项目选项卡,选择运行,然后选择mockup_app作为运行配置。

现在,你可以用鼠标右键单击该库项目,并选择编译:.so文件将创建

看起来问题是,运行配置(没有从早期版本的QtCreator)需要一个应用程序被选中....当是没有的,一个lib被选中,然后编译甚至没有启动。

编辑2015年7月20日:这是一个Qt的bug,我填一个bug报告:的https: //bugreports.qt.io/browse/QTCREATORBUG-14710 它是固定的。 QtCreator的下一个版本应该罚款。

I am using the SMTP Client project to create a library file (.dll) on Windows. Everything works fine and e-mails are sent successfully.

I want to port my Qt project to Android and since Android is a different architecture I need to build the library using a Android armv7 toolkit.

I try this, but I get error:

Internal Error: Unknown Android deployment JSON file location. Error while building/deploying project SMTPEmail (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.4.2)) When executing step "Build Android APK"

I suspect there is something I have to add/remove from the project file. I see there is a "win32:CONFIG += dll", but nothing similar for other platforms.

The .pro files looks like this:

#-------------------------------------------------
#
# Project created by QtCreator 2011-08-11T20:59:25
#
#-------------------------------------------------

QT       += core network

TARGET = SMTPEmail

# Build as an application
#TEMPLATE = app

# Build as a library
TEMPLATE = lib
DEFINES += SMTP_BUILD
win32:CONFIG += dll

QMAKE_CXXFLAGS += -fPIC

SOURCES += \
    src/emailaddress.cpp \
    src/mimeattachment.cpp \
    src/mimefile.cpp \
    src/mimehtml.cpp \
    src/mimeinlinefile.cpp \
    src/mimemessage.cpp \
    src/mimepart.cpp \
    src/mimetext.cpp \
    src/smtpclient.cpp \
    src/quotedprintable.cpp \
    src/mimemultipart.cpp \
    src/mimecontentformatter.cpp \

HEADERS  += \
    src/emailaddress.h \
    src/mimeattachment.h \
    src/mimefile.h \
    src/mimehtml.h \
    src/mimeinlinefile.h \
    src/mimemessage.h \
    src/mimepart.h \
    src/mimetext.h \
    src/smtpclient.h \
    src/SmtpMime \
    src/quotedprintable.h \
    src/mimemultipart.h \
    src/mimecontentformatter.h \
    src/smtpexports.h

OTHER_FILES += \
    LICENSE \
    README.md

FORMS +=

解决方案

As commented in the OP, I had the same problem and could fix it by simply adding an application to my project.

My original project was a simple .pro file targetting a library (tinyxml). With Qt 5.2.1 (Qt Creator 3.0.1), I was able to compile the library for Android (creating a .so file). With Qt 5.5.0 (Qt Creator 3.4.0), I had the same error message as reported in the OP.

Here is my solution:

I created another .pro file targetting a dummy program:

mockup_app.pro:

TARGET = mockup_app
SOURCES += main.cpp
TEMPLATE = app

main.cpp:

// actually never compiled
int main()
{
    return 0;
}

toplevel.pro:

TEMPLATE = subdirs
SUBDIRS += tinyxml.pro
SUBDIRS += mockup_app.pro

Then, open toplevel.pro. Go to "Projects" tab, select "Run" and then select "mockup_app" as "Run configuration".

Now, you can right-click the library project and select "Compile": .so file will be created.

Looks like the problem is that "Run configuration" (absent from earlier QtCreator versions) needs an app to be selected....and when there is none, a lib is selected and then compilation does not even start.

Edit 07-20-2015: It's a Qt bug, I filled a bug report: https://bugreports.qt.io/browse/QTCREATORBUG-14710 and it was fixed. Next release of QtCreator should be fine.

这篇关于建设SMTP客户端的Qt为针对Android目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆