Qt5 - Windows :Windows cannot find executable

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 18:28:36

问题


I am trying to build a project using Windows 10 and Qt5.12. The small program is using the smtp protocol available here. I can confirm that on my Windows I have the OpenSSL 1.1.1c 28 May 2019. On my Ubuntu 19.04 the same exact program compiles and run as usual but not on Windows.

I git clone my repository into Windows, followed successfully this post and the program builds correctly.

The problem is that when I run it, it cannot find the executable and is asking for it as it is possible to see from the print screen below:

here is my .pro file:

QT += quick quickcontrols2 concurrent network core gui

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Refer to the documentation for the
# deprecated API to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

TARGET = SMTPEmail
DEFINES += SMTP_BUILD

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
        main.cpp \
        progressbardialog.cpp \
        robot.cpp \
        robotmanager.cpp \
        settings/emailaddress.cpp \
        settings/mimeattachment.cpp \
        settings/mimecontentformatter.cpp \
        settings/mimefile.cpp \
        settings/mimehtml.cpp \
        settings/mimeinlinefile.cpp \
        settings/mimemessage.cpp \
        settings/mimemultipart.cpp \
        settings/mimepart.cpp \
        settings/mimetext.cpp \
        settings/quotedprintable.cpp \
        settings/smtpclient.cpp \
        user.cpp \
        usermanager.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =

HEADERS += \
    progressbardialog.h \
    robot.h \
    robotmanager.h \
    settings/SmtpMime \
    settings/emailaddress.h \
    settings/mimeattachment.h \
    settings/mimecontentformatter.h \
    settings/mimefile.h \
    settings/mimehtml.h \
    settings/mimeinlinefile.h \
    settings/mimemessage.h \
    settings/mimemultipart.h \
    settings/mimepart.h \
    settings/mimetext.h \
    settings/quotedprintable.h \
    settings/smtpclient.h \
    settings/smtpexports.h \
    user.h \
    usermanager.h

On my Desktop it is created automatically the build folder and thought that the executable would have been here. Below I Am also attaching a print screen of what is inside the build folder:

Originally this project was deployed on Ubuntu and that gave me no problem. I git clone that repo into my Windows, added the missing SMTP_BUILD but I can't fine the executable that the window in the print screen is asking. What am I missing for this final step?

Thank you very much for pointing in the right direction.


回答1:


As shown in the image of your .pro you are using TEMPLATE = lib whose objective is to create a library whose product is a .dll, .so, etc. that is not an .exe.

If you want to generate an executable you must use:

TEMPLATE = app

Plus:

To make it easier to include the library in your project, I have created this project whose objective is to provide a .pri that is easy to link to any project with .pro. To do this you must follow the following steps:

  • Download the project
  • Add include(/path/of/SMTPEmail.pri) to your .pro
  • Includes using #include <SmtpMime>


来源:https://stackoverflow.com/questions/59271296/qt5-windows-windows-cannot-find-executable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!