'LINK Error when trying to use OpenSSL evp aes 256 c++

i have a lot of LINK error when i'm trying to use the evp aes encryption template code from OpenSSL documentation : https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption

I have this type of error when i try to compile :

libcrypto.lib(b_sock.obj) : error LNK2019: symbole externe non résolu __imp__ioctlsocket@12 référencé dans la fonction _BIO_socket_ioctl

libcrypto.lib(b_sock.obj) : error LNK2019: symbole externe non résolu __imp__getsockname@12 référencé dans la fonction _BIO_sock_info

I include my lib file (libcrypto.lib) and all headers files. Other code without evp work.

I'm developping on Clion with Visual Studio compiler (C++ 17)



Solution 1:[1]

Those missing symbols are provided by the windows ws2_32 library. This is documented, for example, at the bottom of the documentation page of the ioctlsocket function. To resolve those symbols, you have to add ws2_32.lib as a dependency to your project.

You may have to add more libraries, as briefly mentioned in the OpenSSL note NOTES.WIN.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1