2

I am statically linking OpenSSL libraries (on Windows) but I have around 30 linker errors, similar like this one:

libcrypto_static.lib(o_names.obj) : error LNK2001: unresolved external symbol __imp__stricmp

As recommended, I used the directives:

pragma comment(lib, "crypt32") pragma comment(lib, "ws2_32.lib") also linker settings:

Ignore Specific Default Libraries: libcmt.lib; msvcrt.lib;msvcrtd.lib

If I remove the msvcrtd.lib from above, I can compile. But it is not correct as the msvcrtd.lib is used for dynamic linking and I wanted to link statically. The compiler should find missing definitions in libcmtd.lib (debug version). The compilation is using the /MT flag to use static linking.

What am I missing? it seems to me, that OpenSSL static crypto library still needs MS run-time dynamic DLL.

query
  • 329
  • 7
  • 18
  • You need to use /MTd for the debug version and /MT for the release version. Do not explicitly ignore libcmt or libcmtd. – n. m. could be an AI Sep 04 '19 at 03:46
  • Yes, I am using MT or MTd as needed. Ignoring libcmt.lib is recommended by MS. The result should be that the debug version of library will be used: libcmtd.lib – query Sep 04 '19 at 04:37
  • It looks like you need to rebuild libcrypto and libssl with these flags. libcrypto_static.lib is a static library itself but it links with the dynamic MS runtime. – n. m. could be an AI Sep 04 '19 at 04:50
  • https://stackoverflow.com/questions/18486243/how-do-i-build-openssl-statically-linked-against-windows-runtime – n. m. could be an AI Sep 04 '19 at 04:52
  • Yes, as mentoned in the last comment in your link, the OpenSSL is using MT nowadays. I am thinking, as they remove all default libraries during OpenSSL build, I should add some. Which one? – query Sep 04 '19 at 05:06
  • I'm not sure what you mean. The __imp decoration means the library is built with /MD. – n. m. could be an AI Sep 04 '19 at 05:18
  • This solution [compiling the openssl binary statically](https://stackoverflow.com/a/63607013/7535705) – un-CharlieH Aug 28 '20 at 16:33

0 Answers0