Overview
Features
Download
Documentation
Community
Add-Ons & Services

Include static libs into another one

Please post support and help requests here.

Include static libs into another one

Postby dbarzo » 04 Apr 2013, 15:23

Hi,

I'm developing an SDK (as dynamic and static lib) using Poco, and I would like to embed the Poco static libs into my one to avoid the end user to setup the Poco enviroment.
The C/C++ settings for the MySDK.DLL are:

Code: Select all
/I"..\..\..\include" /I"..\..\..\src" /I"D:\lib\boost_1_53_0\" /I"..\..\..\thirdparty" /I"..\..\..\thirdparty\protobuf\include\" /ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "DLL_EXPORT" /D "USING_POCO_LIB" /D "IBPP_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /D "_WINDLL" /D "_MBCS" /Gm /EHa /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Debug_Dyn\MySDK.pch" /Fa"Debug_Dyn\" /Fo"Debug_Dyn\" /Fd"Debug_Dyn\vc100.pdb" /Gd /analyze- /errorReport:queue


The linker settings are:

Code: Select all
/OUT:"..\MySDK.dll" /NOLOGO /LIBPATH:"D:\lib\boost_1_53_0\stage\lib" /LIBPATH:"D:\lib\poco-1.4.6\lib" /DLL "libprotobufd.lib" "PocoDatamdd.lib" "PocoDataODBCmdd.lib" "PocoFoundationmdd.lib" "PocoNetmdd.lib" "PocoUtilmdd.lib" "PocoXMLmdd.lib" "PocoZipmdd.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:"Debug_Dyn\MySDK.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"D:\src\MySDK\bin\dynamic\MySDK.pdb" /MAP":D:\src\MySDK\dynamic\MySDK.map" /PGD:"D:\src\MySDK\bin\dynamic\MySDK.pgd" /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE


But when I build the DLL I get the linker errors like:

Code: Select all
PocoFoundationd.lib(PocoFoundationd.dll) : error LNK2005: "public: __thiscall Poco::NullPointerException::NullPointerException(int)" (??0NullPointerException@Poco@@QAE@H@Z) already defined in PocoFoundationmdd.lib(Exception.obj)


Also when I build the static version, and then build its test program I get the linker error:

Code: Select all
LINK : fatal error LNK1104: unable to open file 'PocoFoundationd.lib'

And I don't understand why it try to search that lib!

Maybe I wrong something stupid but I cannot figure out! :(
Could someone give me some suggestions?

Regards,
Daniele.
dbarzo
 
Posts: 39
Joined: 14 Jan 2013, 17:15
Location: Italy

Re: Include static libs into another one

Postby alex » 04 Apr 2013, 16:02

you should define POCO_STATIC; also, unless you define POCO_NO_AUTOMATIC_LIBS, libraries are linked automatically in headers.
alex
 
Posts: 1146
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Include static libs into another one

Postby dbarzo » 04 Apr 2013, 16:49

Hi Alex!
Thanks a lot for your quickly reply!
I add the two defines to my project but now, when I build the test program I get the linker error:

Code: Select all
LINK : fatal error LNK1104: unable to open file 'PocoFoundationmdd.lib'

which should be "inside" the MySDK.lib
Looking into Foundation.h the automatic linking is correctly disabled.
To solve the error I have to add the \poco-1.4.6\lib to the linker LIBPATH of the test project.

Regards,
Daniele.
dbarzo
 
Posts: 39
Joined: 14 Jan 2013, 17:15
Location: Italy

Re: Include static libs into another one

Postby dbarzo » 05 Apr 2013, 09:22

Is there a way to avoid the necessity to add the \poco-1.4.6\lib to the linker LIBPATH of the test project?

Regards,
Daniele.
dbarzo
 
Posts: 39
Joined: 14 Jan 2013, 17:15
Location: Italy

Re: Include static libs into another one

Postby dbarzo » 08 Apr 2013, 15:48

Hi,

When I build my SDK I get the following linker warning:

Code: Select all
PocoFoundationmdd.lib(ByteOrder.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

PocoFoundationmdd.lib(String.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

PocoFoundationmdd.lib(SignalHandler.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

PocoFoundationmdd.lib(WS2_32.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in PocoFoundationmdd.lib(IPHLPAPI.DLL);  second definition ignored

PocoFoundationmdd.lib(WS2_32.dll) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library

PocoXMLmdd.lib(XMLString.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library


Searching around, I found this article http://blogs.msdn.com/b/vcblog/archive/2009/07/21/linker-warning-lnk4221-and-some-tips-to-avoid-it.aspx (see the section 'Build a static library with other static libraries') but referring to this case, I don't understand why this happen.

Is this warning may be the cause?

Regards,
Daniele.
dbarzo
 
Posts: 39
Joined: 14 Jan 2013, 17:15
Location: Italy


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest