Home > Mobile >  Missing libcrypto.lib in CMake build of Poco project
Missing libcrypto.lib in CMake build of Poco project

Time:09-21

The Poco Libraries can be really powerful and useful... but also stubbornly hard to build :-( I am now several days into a process of trying to upgrade from:

  • Poco 1.9.0, win32 build, including NetSSL_OpenSSL and Data/MySQL, on Windows 7, using MS Visual Studio 2015 successfully built via buildwin.cmd script from Windows Explorer since April 2018

to:

  • Poco 1.10.1, win32 and x64 builds, including NetSSL_OpenSSL and Data/MySQL (32-bit) or Data/PostgreSQL (64-bit), on Windows 10, using MS Visual Studio 2019, built via any means at all.

So far I cannot make the build process budge in any significant direction from my old build to my new target via any means... except possibly via CMake.

Since CMake appears to be the preferred way to build Poco, and nothing else (e.g. buildwin.cmd) works as expected, I am trying to rebuild the 32-bit DLLs so I can test with older proven components in my application. It looks promising. But the crypto build complains:

LINK : fatal error LNK1104: cannot open file 'libcrypto.lib' [S:\3rdparty\Poco-build32\Crypto\Crypto.vcxproj]

That's strange: in the entire Crypto.vcxproj file, there is no mention of libcrypto.lib at all, only libcrypto32MD.lib and libcrypto32MDd.lib. Why is it even looking for libcrypto.lib? Even so, if it is supposed to be finding libcrypto.lib, why doesn't it succeed when it is freshly installed in C:\Program Files (x86)\OpenSSL-Win32\lib and OPENSSL_ROOT_DIR is set to C:\Program Files (x86)\OpenSSL-Win32? What am I missing? I got to this point via:

cmake -HS:\3rdparty\Poco -B S:\3rdparty\Poco-build32 -G "Visual Studio 16 2019" -A win32
cmake --build s:\3rdparty\Poco-build32 --config RelWithDebInfo

UPDATE: in case I modified anything while trying to make it build in other ways (buildwin.cmd, Batch Build in Visual Studio), I set the entire Poco file structure aside, and unzipped a fresh copy. The OpenSSL install is also fresh and untouched. The x64 build produces the identical error...

CodePudding user response:

There is a hidden readme file https://github.com/pocoproject/poco/blob/master/README. I'm quoting:

Through the Poco/Crypto/Crypto.h and Poco/Net/NetSSL.h header files, Visual C will automatically link the libcrypto.lib and libssl.lib libraries. If your OpenSSL libraries are named differently, compile with the macro POCO_EXTERNAL_OPENSSL defined and edit the project files accordingly.

You can try to re-compile with the POCO_EXTERNAL_OPENSSL macro set accordingly (see Foundation/include/Poco/Config.h). (source)

Or what I did. Edit the file Crypto/include/Poco/Crypto/Crypto.h, remove all if-else logic around pragmas and leave only libraries that use have:

#pragma comment(lib, "libcrypto64md.lib")
#pragma comment(lib, "libssl64md.lib")

CodePudding user response:

This is not a direct answer - it is an alternative build path that has been confirmed to produce viable DLLs. Try:

  • Start command line tool from Visual Studio
  • Invoke vcvars32.bat or vcvars64.bat to ensure environment is correct for Win32 or x64 build.
    • I found these scripts in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build
  • Ensure the Poco buildwin.cmd script is configured to specify location of OpenSSL include and lib sub-folders
    • you will likely have to modify the script between builds if building both 32- and 64-bit builds since openSSL-Win32 and openSSL-Win64 are separate installations
    • specify include and lib paths for other components the same way (e.g. MySQL and/or PostgreSQL, etc)
  • Edit the Poco "components" file to eliminate any components not required that will stop build
  • Invoke buildwin, e.g.:
    • buildwin 160 shared both Win32 samples notests
    • buildwin 160 shared both x64 samples notests
  • Related