【发布时间】:2019-12-09 21:12:40
【问题描述】:
我正在尝试使用Windows 10 和Qt5.12 构建一个项目。小程序使用smtp 协议可用here。我可以确认在我的Windows 上我有OpenSSL 1.1.1c 28 May 2019。
在我的Ubuntu 19.04 上,同样的程序像往常一样编译和运行,但在Windows 上却没有。
我附在错误的打印屏幕下方;然而,这些大多是两种类型:
1) inconsistent dll linkage
2) definition of dllimport static data member not allowed
在this link 之后,Windows 似乎需要其“自己的”包含(即#include <windows....),但在我的情况下,来自上述链接的smtp 库没有任何#include <windows> 并且不知道如果必须生成它们。我发现的帖子似乎不是他们
此外,我正在阅读this post too,因为我认为我可能有用,但没有任何信息可以帮助我解决问题
我挖了更多,实际上去了windows includes所在的位置,以下是我能够找到的路径,但不知道这是否有用:
从我红色的所有帖子来看,问题似乎是,在这种特定情况下,Windows
.pro 文件已写入。在我的.pro 文件下方。
请注意,我将此存储库克隆到我的windows 10 中。
.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
TEMPLATE = lib
DEFINES += SMTP_BUILD
win32:CONFIG += dll
# 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
编辑
更具体地说,违规行的每个标题似乎都如下:
class SMTP_EXPORT EmailAddress : public QObject // <-- SMTP_EXPORT
这导致我在下面复制的 smtpexports.h:
#ifndef SMTPEXPORTS_H
#define SMTPEXPORTS_H
#ifdef SMTP_BUILD
#define SMTP_EXPORT Q_DECL_EXPORT
#else
#define SMTP_EXPORT Q_DECL_IMPORT
#endif
#endif // SMTPEXPORTS_H
其他编辑
添加DEFINES += SMTP_BUILD 后几乎所有错误都解决了,但我还有两个错误,我在下面添加了一个打印屏幕:
非常感谢您指出如何解决此问题的正确方向。
【问题讨论】: