Search code examples
windowsstatic-linkingpoco-libraries

Poco as static library with dynamic runtime requires import library of DLL?


I'm trying to use Poco as a static library with dynamic runtime inside my project. I've downloaded the complete sources of Poco 1.7.3 and used the buildwin.bat script to compile the libraries using my self-compiled OpenSSL 1.0.2h shared library (i.e. adjusted the path in buildwin.bat).

Producing PocoXYZmd.lib via buildwin.bat 140 build static_md debug Win32 nosamples notests msbuild works fine.

However, when I try to link against PocoXYZmd.lib inside my own project, the linker searches for PocoXYZ.lib, the import library for PocoXYZ.dll.

Building Poco with shared and providing the PocoXYZ.lib import libraries within the linker search path, I'm getting errors on Poco symbols being already defined (obviously).

Am I missing something crucial or is it a bug in Poco's build script?


I've configured Poco to ONLY build the following components: Foundation, XML, JSON, Util, Net, Crypto, NetSSL_OpenSSL.

In addition, I had to adjust the v140 vcxproj-files of Crypto and NetSSL_OpenSSL to link to libeay32.lib and ssleay32.lib (the import libraries for the OpenSSL DLLs) instead of libeay32md.lib and ssleay32md.lib (no idea where these could come from based on the OpenSSL 1.0.2h build scripts).

I'm using Visual Studio 2015 Update 2 on Windows 7, doing everything within the 32bit Visual Studio Developer Prompt.


Solution

  • After re-reading the Poco documentation, I finally found the solution:

    When using Poco statically on Windows, one must specify POCO_STATIC when compiling the library/application using Poco, otherwise several #pragma comment directives in Poco's headers will silently force linking to the DLL version of Poco.

    http://pocoproject.org/docs/99150-WindowsPlatformNotes.html

    Thanks, RTFM.