openssl x64 static libs can't link in Visual Studio 2015

patcherton.fixesthings's Avatar

patcherton.fixesthings

04 Nov, 2019 04:35 AM

Using the Visual Studio 2015 image and trying to link against c:\openssl-win64\lib\VC\static\libeay32MT.lib and c:\openssl-win64\lib\VC\static\ssleay32MT.lib

I'm getting these errors:
ssleay32MT.lib(t1_enc.obj) : error LNK2001: unresolved external symbol __iob_func
libeay32MT.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __iob_func
libeay32MT.lib(eng_openssl.obj) : error LNK2001: unresolved external symbol __iob_func
libeay32MT.lib(txt_db.obj) : error LNK2001: unresolved external symbol __iob_func
libeay32MT.lib(ui_openssl.obj) : error LNK2001: unresolved external symbol __iob_func

A quick search indicates that it might mean that these libs were built with a previous version of MSVC and are not compatible with 2015. Do they need to be updated in the Visual Studio 2015 image?

  1. Support Staff 1 Posted by Feodor Fitsner on 05 Nov, 2019 05:58 PM

    Feodor Fitsner's Avatar

    What version of OpenSSL would you need on VS 2015 image?

  2. 2 Posted by patcherton.fixe... on 05 Nov, 2019 08:01 PM

    patcherton.fixesthings's Avatar

    The version of openssl isn't what's important. What's important is that the .libs need to have been compiled with VS 2015 (or possibly later) because Microsoft changed __iob_func to __acrt_iob_func

    From https://docs.microsoft.com/en-us/cpp/porting/visual-cpp-change-history-2003-2015?redirectedfrom=MSDN&view=vs-2019#stdio_and_conio

    "If your project links with static libraries that were compiled with a release of Visual Studio earlier than 2015, the linker might report an unresolved external symbol. These errors might reference internal definitions for _iob, _iob_func, or related imports for certain <stdio.h> functions in the form of imp*. Microsoft recommends that you recompile all static libraries with the latest version of the C++ compiler and libraries when you upgrade a project."

  3. Support Staff 3 Posted by Feodor Fitsner on 05 Nov, 2019 08:33 PM

    Feodor Fitsner's Avatar

    OK, but we are not compiling OpenSSL libraries by ourselves, but rather install them from pre-built packages. There is a bunch of OpenSSL versions/releases on build VM: https://www.appveyor.com/docs/windows-images-software/#tools

    The script installing them: https://github.com/appveyor/build-images/blob/master/scripts/Window...

  4. 4 Posted by patcherton.fixe... on 05 Nov, 2019 09:05 PM

    patcherton.fixesthings's Avatar

    but we are not compiling OpenSSL libraries by ourselves, but rather install them from pre-built packages

    It's still the case that the preinstalled static libraries do not work regardless of where they came from. :(

  5. 5 Posted by patcherton.fixe... on 10 Nov, 2019 07:22 PM

    patcherton.fixesthings's Avatar

    Is there any chance you could replace the packages in those builds with ones built with the right version of MSVC? See for instance: https://www.npcglib.org/~stathis/blog/precompiled-openssl/

    Statically linking against AppVeyor's currently installed C:\OpenSSL-Win64\ fails, but passes if you replace it with the MSVC 2015 binaries from https://www.npcglib.org/~stathis/downloads/openssl-1.0.2l-vs2015.7z

    Why include libraries that are guaranteed to not work?

  6. Support Staff 6 Posted by Feodor Fitsner on 11 Nov, 2019 05:07 PM

    Feodor Fitsner's Avatar

    Thanks for pointing that out. If there are more requests to replace OpenSSL libs with alternative release we'd certainly do that. For now I assume you can easily download and replace them during your build.

  7. Feodor Fitsner closed this discussion on 03 Apr, 2020 06:46 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac