编译到 MinGW 时出现 OpenSSL 错误



我正在尝试在Qt 5.15.2 + MinGW 7.3.0 + OpenSSL 1.1.1上构建这个项目(https://github.com/decentralised-project/decentralised_ui)。构建时,我按照说明进行操作,库都在工作,但输出这些错误(这些函数在此版本的 OpenSSL 中)

undefined reference to `EC_KEY_free'
undefined reference to `EC_POINT_free'
undefined reference to `EC_KEY_free'
undefined reference to `EC_KEY_free'
undefined reference to `EC_POINT_free'
undefined reference to `BIO_s_mem'
undefined reference to `BIO_new'
undefined reference to `EC_GROUP_new_by_curve_name'
undefined reference to `PEM_write_bio_ECPrivateKey'
undefined reference to `PEM_write_bio_ECPKParameters'
undefined reference to `PEM_write_bio_EC_PUBKEY'
undefined reference to `BIO_read'
undefined reference to `BIO_free_all'
undefined reference to `EC_GROUP_free'
undefined reference to `EC_KEY_free'
undefined reference to `EC_KEY_new'
undefined reference to `EC_GROUP_new_by_curve_name'
undefined reference to `EC_KEY_set_group'

.pro 文件

QT       += core gui
QT       += network widgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
win32:CONFIG(release, debug|release): LIBS += -L"C:/OpenSSL-Win32/lib/MinGW/libssl.a"
win32:CONFIG(release, debug|release): LIBS += -L"C:/OpenSSL-Win32/lib/MinGW/libcrypto.a"
win32: LIBS += -lgdi32 -lws2_32 -ladvapi32 -lcrypt32 -luser32
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../dependencies/decentralised_p2p/src/release/ -ldecentralised_p2p
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../dependencies/decentralised_p2p/build-decentralised_p2p-Desktop_Qt_5_8_0_MSVC2013_64bit2-Debug/debug/ -ldecentralised_p2p
else:macx: LIBS += -L$$PWD/../dependencies/decentralised_p2p/build-decentralised_p2p-Desktop_Qt_5_8_0_clang_64bit-Debug  -ldecentralised_p2p
else:unix: LIBS += -L$$PWD/../dependencies/decentralised_p2p/build-decentralised_p2p-Desktop-Debug/ -ldecentralised_p2p
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../dependencies/decentralised_data/src/release/ -ldecentralised_data
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../dependencies/decentralised_data/build-decentralised_data-Desktop_Qt_5_8_0_MSVC2013_64bit2-Debug/debug/ -ldecentralised_data
else:unix: LIBS += -L$$PWD/../dependencies/decentralised_data/build-decentralised_data-build-decentralised_p2p-Desktop-Debug-Debug/ -ldecentralised_data
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../dependencies/decentralised_crypt/src/release/ -ldecentralised_crypt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../dependencies/decentralised_crypt/build-decentralised_crypt-Desktop_Qt_5_8_0_MSVC2013_64bit2-Debug/debug/ -ldecentralised_crypt
else:unix: LIBS += -L$$PWD/../dependencies/decentralised_crypt/build-decentralised_crypt-build-decentralised_p2p-Desktop-Debug-Debug/ -ldecentralised_crypt
INCLUDEPATH += $$PWD/../dependencies/decentralised_p2p/src
DEPENDPATH += $$PWD/../dependencies/decentralised_p2p/src/release
INCLUDEPATH += $$PWD/../dependencies/decentralised_data/src
DEPENDPATH += $$PWD/../dependencies/decentralised_data/src/release
INCLUDEPATH += $$PWD/../dependencies/decentralised_crypt/src
DEPENDPATH += $$PWD/../dependencies/decentralised_crypt/src/release
win32: DEFINES += WINDOWS
macx: DEFINES += MACOSX
win32:INCLUDEPATH += "C:/OpenSSL-Win32/include/"
TARGET = decentralised_ui
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += static
# You can also make your code fail to compile if you use 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
mainwindow.cpp 
logindialog.cpp 
aboutdialog.cpp 
preferencesdialog.cpp 
settings.cpp 
newuserdialog.cpp
HEADERS  += mainwindow.h 
logindialog.h 
aboutdialog.h 
preferencesdialog.h 
settings.h 
newuserdialog.h
FORMS    += mainwindow.ui 
logindialog.ui 
aboutdialog.ui 
preferencesdialog.ui 
newuserdialog.ui
RC_FILE = dc.rc
DISTFILES += 
dc.rc
RESOURCES += 
resources.qrc
TRANSLATIONS    = decentralised_pt.ts 
decentralised_ru.ts 
decentralised_de.ts

MinGW 7.3.0 是旧的。我建议改用较新的MinGW-w64/

-L"C:/OpenSSL-Win32/lib/MinGW/libssl.a"-L"C:/OpenSSL-Win32/lib/MinGW/libcrypto.a"不正确。

使用-L指定查找.a文件的路径,-l指定实际库(但不带扩展名和lib前缀)。

所以而不是

-L"C:/OpenSSL-Win32/lib/MinGW/libssl.a"
-L"C:/OpenSSL-Win32/lib/MinGW/libcrypto.a"

你应该使用

-L"C:/OpenSSL-Win32/lib/MinGW" -lssl -lcrypto

由于顺序对于 MinGW/MinGW-w64 很重要,因此您还需要确保在调用这些库的任何对象之后指定这些-l标志。

相关内容

  • 没有找到相关文章

最新更新