Undefined reference to SSL_library_init and SSL_load_error_strings

前端 未结 4 416
眼角桃花
眼角桃花 2020-12-17 15:19

I am implementing a OpenSSL code and have already included required header files but still I am getting errors like *

undefined reference to SSL

相关标签:
4条回答
  • 2020-12-17 15:23

    ldd libssl.so -> libcrypto.so.1.1 => not found

    sudo ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

    libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f17d46c7000)

    0 讨论(0)
  • 2020-12-17 15:25

    For me this meant to install

     apt install libssl1.0-dev
    
    0 讨论(0)
  • 2020-12-17 15:37

    Link against libssl and libcrypto. Your LDFLAGS and LDLIBS would be as follows. Order matters for LDLIBS:

    LDFLAGS = -L/usr/local/ssl/lib
    LDLIBS = -lssl -lcrypto
    

    Don't worry about adding the "lib" in front of library name, or the "so" or "a" suffix. The linker will do it for you.

    If you are building from the command line, then you would use the following. Again, order matters.

    gcc foo.c -o foo.exe -L/usr/local/ssl/lib -lssl -lcrypto
    

    If you are using the system's OpenSSL, then you can omit -L/usr/local/ssl/lib.

    0 讨论(0)
  • 2020-12-17 15:38

    These methods are deprecated in OpenSSL 1.1. You don't need to use it more. You can just remove it. More info in OpenSSL manual.

    0 讨论(0)
提交回复
热议问题