Ed Vestorn
Ed Vestorn

Reputation: 38

OpenSSL errors when compiling to MinGW

I'm trying to build this project (https://github.com/decentralised-project/decentralised_ui ) on Qt 5.15.2 + MinGW 7.3.0 + OpenSSL 1.1.1. When building, I acted according to the instructions, the libraries are all working, but outputs these errors (these functions are in this version of 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 file

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

Upvotes: 0

Views: 445

Answers (1)

Brecht Sanders
Brecht Sanders

Reputation: 7287

MinGW 7.3.0 is old. I recommend using newer MinGW-w64 instead/

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

Use -L to specify a path where to look for .a files and -l to specify the actualy library (but without extension and lib prefix).

So instead of

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

you should use

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

Since order is important with MinGW/MinGW-w64 you also need to make sure these -l flags are specified after any objects that call these libraries.

Upvotes: 1

Related Questions