1

I have followed a tutorial on how to build and Link OpenSSL using Visual Studios however when testing I have got loads of Linker errors which leads me to belive that I probably did something wrong when setting up OpenSSL.

One of the errors I got (they all looked very similar): LNK2001 Not resolved extern Symbol "__imp_gethostbyname" - libcrypto.lib(libcrypto-lib-bio_addr.obj)

I got a total of 34 of those kind of error messages (sorry if my translation of the exact error message is not 100% accurate as my Visual Studio isn't in english).

So the way I Linked the Library following my tutorial was as follows:

  1. Add include directory path to "Settings->General->Additional Includedirectorys"

  2. Add lib directory path to "Linker->General->Additional Librarydirectorys"

  3. Add "libcrypto.lib" and "libssl.lib" to "Linker->Input->Additional dependencies" enter image description here

DarkCoder
  • 23
  • 3
  • 1
    You need to link with the Microsoft library `Ws2_32.lib` as stated in this msdn documentation: [https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-gethostbyname](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-gethostbyname) – drescherjm Oct 15 '21 at 12:32
  • You should have a look at this page. https://stackoverflow.com/questions/32156336/how-to-include-openssl-in-visual-studio – Tpeng Oct 15 '21 at 12:53
  • Why do I need to link that library (and how would I do that - sorry if it isn't obvious to me as I am a beginner in terms of using c++ librarys)? I have not seen that in any guide for implementing openssl. This "__imp_gethostbyname" link error is (as stated in my question) not my only link error. To me it looks more like I forgot something in the configuration and setup of openssl just because of the ammount of errors and also because it says "libcrypto.lib" in every single line of the "file" column of the error message tab. – DarkCoder Oct 20 '21 at 12:43

1 Answers1

0

DLL improves the maintainability of the program,you may need to know about the dynamic link library, please refer to the document: Create and use your own Dynamic Link Library (C++). And you could refer to the comment to add OpenSSL in your project. In addition, according to your path, you seem to be using a static library.

Minxin Yu - MSFT
  • 2,234
  • 1
  • 3
  • 14