C ++ POCO lib Binding Error while trying to static link VS9 express

Preview: binding error while trying to static link VS9 express

I am trying to compile a simple application in visual studio 2008 express based on Poco::Process . But I get communication errors.

Here is my simple code configured as a console application:

 #include "Poco/Foundation.h" #include "Poco/Process.h" #include "Poco/Pipe.h" #include "Poco/PipeStream.h" using Poco::Process; using Poco::ProcessHandle; using Poco::Pipe; using Poco::PipeInputStream; using Poco::PipeOutputStream; int main(int argc, char** argv) { std::string cmd = "hostname"; std::vector<std::string> args; args.push_back("--help"); ProcessHandle ph = Process::launch(cmd, args); int rc = ph.wait(); return 0; } 

I added preprocess flags:

 Foundation_EXPORTS POCO_STATIC PCRE_STATIC 

And I am contacting:

 PocoFoundationmt.lib 

with multi-threaded Debug DLL (/ MDd), but I get this binding error:

 1>poco_process.cpp 1>Linking... 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" ( ??1?$basic_string@DU ?$char_traits@D @ std@ @ V?$allocator@D @ 2@ @ std@ @ QAE@XZ ) already defined in PocoFoundationmt.lib(Process.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" ( ??0?$basic_string@DU ?$char_traits@D @ std@ @ V?$allocator@D @ 2@ @ std@ @ QAE@PBD @Z) already defined in PocoFoundationmt.lib(Process.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ( ??0?$basic_string@DU ?$char_traits@D @ std@ @ V?$allocator@D @ 2@ @ std@ @ QAE@ABV01 @@Z) already defined in PocoFoundationmt.lib(Bugcheck.obj) 1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" ( ?_Decref@facet @ locale@std @@ QAEPAV123@XZ ) already defined in PocoFoundationmt.lib(Bugcheck.obj) 1>libcpmt.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" ( ?_Addstd@ios _base@std @@ SAXPAV12@ @Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmt.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" ( ?_Ios_base_dtor@ios _base@std @@ CAXPAV12@ @Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmt.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl*)(void))" ( ?_AtModuleExit@ @ YAXP6AXXZ@Z ) already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" ( ?_Getgloballocale@locale @ std@ @ CAPAV_Locimp@12 @XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmt.lib(locale0.obj) : error LNK2005: __Fac_tidy already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmt.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" ( ?facet_Register@facet @ locale@std @@ CAXPAV123@ @Z) already defined in msvcprtd.lib(locale0_implib.obj) 1>libcpmt.lib(locale0.obj) : error LNK2005: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " ( ?c_str@ ?$basic_string@DU ?$char_traits@D @ std@ @ V?$allocator@D @ 2@ @ std@ @QBEPBDXZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" ( ?_Locinfo_dtor@ _Locinfo@std @@ SAXPAV12@ @Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" ( ?_Init@locale @ std@ @ CAPAV_Locimp@12 @XZ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ( ?_Locinfo_ctor@ _Locinfo@std @@ SAXPAV12@ABV ?$basic_string@DU ?$char_traits@D @ std@ @ V?$allocator@D @ 2@ @ 2@ @Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" ( ??0_Lockit@std @@ QAE@H @Z) already defined in msvcprtd.lib(MSVCP90D.dll) 1>libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" ( ??1_Lockit@std @@ QAE@XZ ) already defined in msvcprtd.lib(MSVCP90D.dll) 1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(lconv.obj) : error LNK2005: _localeconv already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj) 1>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" ( ?terminate@ @YAXXZ) already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LIBCMT.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj) 1>LIBCMT.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR90D.dll) 1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library 1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library 1>D:\cpp\libs\poco-1.4.1p1\poco-1.4.1p1\Foundation\Debug\poco_process.exe : fatal error LNK1169: one or more multiply defined symbols found 1>Build log was saved at "file://d:\cpp\libs\poco-1.4.1p1\poco-1.4.1p1\poco_process\Debug\BuildLog.htm" 1>poco_process - 38 error(s), 2 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

What am I doing here? Thanks for helping

+1
source share
3 answers

The library "PocoFoundationmt.lib" that you use is built with the "release static" mode. From the project you are running, it looks as if you need a debug version of the library, which should be "PocoFoundationmtd.lib".

As you can see from the error log, there is a conflict when linking. That is, you said that the executable is MDd, but you are linking to the release version library. Make sure that in ProjectProperties-> Linker you do not link to other libraries and make a link to "PocoFoundationmtd.lib" . Be sure to select "Debug" instead of "Release" at the top (start button) of your project. Also specify POCO_STATIC .

+1
source

Make sure you create both the Poco libraries and your project in the same C runtime (static / dynamic, debug / release, multi-threaded).

+1
source

I just did it, as Chadwick said, you don’t need the Foundation_EXPORTS preprocessor flag.

Also, if you installed the additional lib directory in poco lib, you do not need to specify the type dll ie MT, Debug, etc.

You only need POCO_STATIC as a preprocessor flag.

+1
source

All Articles