【问题标题】:Qt5 - Windows :Windows cannot find executableQt5 - Windows:Windows 找不到可执行文件
【发布时间】:2019-12-10 16:08:31
【问题描述】:

我正在尝试使用Windows 10Qt5.12 构建一个项目。小程序使用smtp 协议可用here。我可以确认在我的 Windows 上我有 OpenSSL 1.1.1c 2019 年 5 月 28 日。在我的 Ubuntu 19.04 上,相同的程序可以像往常一样编译和运行,但在 Windows 上没有。

我将git clone我的存储库添加到Windows,成功跟随this post,程序构建正确。

问题是当我运行它时,它 cannot find the executable 并要求它,从下面的打印屏幕中可以看到:

这是我的.pro 文件:

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

在我的桌面上它是自动创建的build 文件夹,并认为可执行文件会在这里。下面我还附上了build 文件夹内内容的打印屏幕:

最初这个项目是在Ubuntu 上部署的,这对我没有任何问题。我将git clone 那个repo 放入我的Windows,添加了缺少的SMTP_BUILD,但我无法处理打印屏幕中的窗口要求的可执行文件。最后一步我缺少什么?

非常感谢您指出正确的方向。

【问题讨论】:

  • 检查 debug/ 子文件夹
  • 在调试或发布中应该是可执行文件。在 QT-Creator 中单击“项目”左键,“构建目录”是什么?如果路径正确,QT-Crator 应该会找到可执行文件。
  • 构建目录是C:\Users\me\OneDrive\Desktop\build-signalsQML-Desktop_Qt_5_12_0_MSVC2017_64bit-Debug
  • this is the debug directory 但我没有看到任何.exe
  • 你确定链接成功了吗?您确定要构建可执行文件吗?

标签: c++ windows c++11 qt5 qt-creator


【解决方案1】:

如您的 .pro 图像所示,您正在使用 TEMPLATE = lib,其目标是创建一个库,其产品是 .dll、.so 等而不是 .exe。

如果要生成可执行文件,必须使用:

TEMPLATE = app

加:

为了更容易将库包含在您的项目中,我创建了this project,其目标是提供一个易于使用 .pro 链接到任何项目的 .pri。为此,您必须遵循以下步骤:

  • 下载项目
  • include(/path/of/SMTPEmail.pri) 添加到您的.pro
  • 包括使用#include <SmtpMime>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-02
    • 2013-11-20
    • 2012-07-22
    • 2017-05-07
    • 1970-01-01
    • 2020-10-25
    相关资源
    最近更新 更多