Skip to content

BUILD_SHARED_LIBS & POCO_STATIC cause #pragma comment(lib, "PocoUtil" POCO_LIB_SUFFIX) to be invalid #4754

@athaa

Description

@athaa

Hello Poco Team,

Describe the bug
The visual studio compiler/linker ask for Foundation.lib instead of Foundationmd.lib

To Reproduce
I build poco from source, as static, with cmake, using BUILD_SHARED_LIBS =OFF. I keep MT=OFF (to use system/compiler dll).
I got files ending with md.lib and mdd.lib => this is what I expected

I add lib and include dependencies to my project (visual studio) using cmake
I add
#include "Foundation.h"
in the main

call compiler OK
call linker NOT OK

Expected behavior

The linker shoud ask for PocoFoundationmd.lib, not for :
Logs

LINK : fatal error LNK1104: cannot open file 'PocoFoundation.lib'

Please add relevant environment information:

  • Windows 10
  • POCO 13.3, from what I can see the same problem should apply to the last version (main)

Additional context
From what I can see it is due to the check performed in Foundation.h

#if defined(_WIN32) && defined(_DLL)
	#if !defined(POCO_DLL) && !defined(POCO_STATIC)
		#define POCO_DLL
	#endif
#endif

It cause the following:
#pragma comment(lib, "PocoUtil" POCO_LIB_SUFFIX)
To be invalid (and all similar #pragma) since POCO_LIB_SUFFIX is created using POCO_DLL.

I supposed it should not use POCO_STATIC here because it is deprecated according the cmakefile:
message(WARNING "POCO_STATIC has been deprecated. Please use BUILD_SHARED_LIBS=NO to build static libraries.")
, but use BUILD_SHARED_LIBS (or a combination of both until complete removal)

BTW, I know the documentation :https://docs.pocoproject.org/current/99150-WindowsPlatformNotes.html
ask to use POCO_STATIC, but I guess the code is supposed to be more up to date. I'm right ?

Sorry if I miss something obvious.

Thanks by advance,

Have a good day

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions