Important: Please read the Qt Code of Conduct -

OpenSSL undefined references

  • Good day, everyone.

    I have some trouble with EVP functions from OpenSSL libraries. The file evp.h was included in project, by:
    "#include <C:\OpenSSL-Win64\include\openssl\evp.h>" and only it was included i project. Nothing more.

    Qt still tells me about "undefined references", something like that:
    @C:\Users\House15\Documents\QtProjects\Server-build-desktop-Qt_4_7_4_for_Desktop_-MinGW_4_4__Qt_SDK________/../Server/myserver.cpp:141: undefined reference to EVP_CIPHER_CTX_init' C:\Users\House15\Documents\QtProjects\Server-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK_________/../Server/myserver.cpp:144: undefined reference toEVP_aes_256_cfb1'
    C:\Users\House15\Documents\QtProjects\Server-build-desktop-Qt_4_7_4_for_Desktop_-MinGW_4_4__Qt_SDK________/../Server/myserver.cpp:147: undefined reference to EVP_EncryptInit' C:\Users\House15\Documents\QtProjects\Server-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK_________/../Server/myserver.cpp:141: undefined reference toEVP_CIPHER_CTX_init'
    C:\Users\House15\Documents\QtProjects\Server-build-desktop-Qt_4_7_4_for_Desktop_-MinGW_4_4__Qt_SDK________/../Server/myserver.cpp:144: undefined reference to EVP_aes_256_cfb1' C:\Users\House15\Documents\QtProjects\Server-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK_________/../Server/myserver.cpp:147: undefined reference toEVP_EncryptInit'@

    Installing the libraries was held step by step:

    1. File C:\Qt\4.7.4\mkspecs\win32-g++\qmake.conf

    @QMAKE_CFLAGS_RELEASE = -O2 -MD@ was changed to @QMAKE_CFLAGS_RELEASE = -O2 -MT@
    @QMAKE_CFLAGS_DEBUG = -Zi -MDd@ was changed to @QMAKE_CFLAGS_DEBUG = -Zi -MTd@

    1. File C:\Qt\4.7.4\mkspecs\win32-g++\qmake.conf
      @CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files
      debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe@
      was changed to:
      @ CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files
      debug_and_release debug_and_release_target@

    3.From Makefile deleting all strings, contains "example" and "demos", just for increasing speed of compilation.
    4. Using Visual studio 2010 command promt, in directory C:\Qt\4.7.4 write this:
    @configure.exe -static -release -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libjpeg -no-crt -openssl -I C:\OpenSSL-Win64\include -L C:\OpenSSL-Win64\lib\VC -qt-sql-odbc -no-webkit@


    6.On error reports about unable libraries <openssl/...>, i react simple:
    changed @# include <openssl / ... @ on the @# include <d :/ src/3rd-party/openssl/include / ...,@ ie, the directory in which I lay these same header files.

    7.Errors which tell us about undefined libraries libeay32MT.lib and ssleay32MT.lib, fixin by renaming libs into libeay32.lib, and ssleay32.lib correspondingly, and put them into C:\Qt\4.7.4\lib. Type "nmake" again.

    8.nmake install.

    I guess, it was a mistake, using Visual Studio, instead MinGW, but when i tried to compile files with MinGW, system says what it's cannot define files like "stdlib.h" and "stdio.h". I just don't khow where this files must lies in MinGW.

    In "PATH" declared only "C:\Qt\4.7.4\bin". I have read, it's enough in a most cases.

    Also heard about LIBS+=-lcrypto, but in .conf file of the project it's exactly unnecessary. Where it must be?

    My .pro file:
    @QT += core gui network sql
    CONFIG+= qaxcontainer crypto

    TARGET = Server
    TEMPLATE = app



    HEADERS += dialog.h
    myserver.h \

    FORMS += dialog.ui
    SOURCES += dialog.cpp main.cpp myclient.cpp myserver.cpp
    Many thanks in advance.

  • What kind of Qt distribution do you use? (VS or MinGW). For example, if you use MinGW version of Qt you must have MinGW version of OpenSSL.

Log in to reply