Trying to link with OpenSSL libraries in Windows



  • Hello!

    I'm making a project which includes a statically linked library which in turn uses OpenSSL.
    I have installed 32-bit OpenSSL from https://slproweb.com/products/Win32OpenSSL.html in default folder.
    I have added to my static library pro file:

    INCLUDEPATH += C:/OpenSSL-Win32/include
    DEPENDPATH += C:/OpenSSL-Win32/include
    

    I have added to my application pro file:

    win32: LIBS += -L"C:/OpenSSL-Win32/lib/MinGW/" -leay32
    

    I get:

    C:\Qt\projects\build-config-Desktop_Qt_5_4_2_MinGW_32bit-Debug\common/../../config/common/QueryLogic.cpp:650: undefined reference to `AES_set_encrypt_key'
    C:\Qt\projects\build-config-Desktop_Qt_5_4_2_MinGW_32bit-Debug\common/../../config/common/QueryLogic.cpp:651: undefined reference to `AES_encrypt'
    

    If I change my application pro file to:

    win32: LIBS += -L"C:/OpenSSL-Win32/lib/MinGW/" -llibeay32
    

    I get:

    C:/Qt/Tools/mingw491_32/bin/../lib/gcc/i686-w64-mingw32/4.9.1/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llibeay32
    

    But libeay32.a is there, in C:/OpenSSL-Win32/lib/MinGW/ folder. How do I link with OpenSSL in Windows?

    Thanks!



  • Linkage is done from right to left. Maybe you're adding your static library after openssl. Put it before.


  • Lifetime Qt Champion

    Hi,

    Do you also have libcrypto in your OpenSSL install ?



  • libcrypto is how it's called on unix systems. On Windows it's libeay32.


  • Moderators

    @azarubkin said:

    I have added to my application pro file:

    win32: LIBS += -L"C:/OpenSSL-Win32/lib/MinGW/" -leay32
    

    This works for me: LIBS += C:/OpenSSL-Win32/lib/libeay32.lib



  • @Leonardo said:

    Linkage is done from right to left. Maybe you're adding your static library after openssl. Put it before.
    Yes, you're right. Moving static library after openssl solved my issue.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.