[program_options] linker error LNK2005 (symbol already defined in object)

Hi, I've got the linker error LNK2005 (http://msdn.microsoft.com/en-us/library/72zdcz6f(VS.80).aspx) using MSVC80 (Studio 2005): libboost_program_options-vc80-mt-1_35.lib(value_semantic.obj) : error LNK2005: "public: __thiscall boost::program_options::invalid_option_value::invalid_option_value(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0invalid_option_value@program_options@boost@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(value_semantic.obj) : error LNK2005: "public: virtual char const * __thiscall boost::program_options::validation_error::what(void)const " (?what@validation_error@program_options@boost@@UBEPBDXZ) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(value_semantic.obj) : error LNK2005: "void __cdecl boost::program_options::validate(class boost::any &,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,int)" (?validate@program_options@boost@@YAXAAVany@2@ABV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@H@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(value_semantic.obj) : error LNK2005: "private: virtual void __thiscall boost::program_options::value_semantic_codecvt_helper<char>::parse(class boost::any &,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > const &,bool)const " (?parse@?$value_semantic_codecvt_helper@D@program_options@boost@@EBEXAAVany@3@ABV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@_N@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(options_description.obj) : error LNK2005: "public: class boost::program_options::options_description_easy_init __thiscall boost::program_options::options_description::add_options(void)" (?add_options@options_description@program_options@boost@@QAE?AVoptions_description_easy_init@23@XZ) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(options_description.obj) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl boost::program_options::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class boost::program_options::options_description const &)" (??6program_options@boost@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV23@ABVoptions_description@01@@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(options_description.obj) : error LNK2005: "public: __thiscall boost::program_options::options_description::options_description(unsigned int)" (??0options_description@program_options@boost@@QAE@I@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(options_description.obj) : error LNK2005: "public: __thiscall boost::program_options::options_description::options_description(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int)" (??0options_description@program_options@boost@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@I@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(options_description.obj) : error LNK2005: "public: class boost::program_options::options_description_easy_init & __thiscall boost::program_options::options_description_easy_init::operator()(char const *,char const *)" (??Roptions_description_easy_init@program_options@boost@@QAEAAV012@PBD0@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(options_description.obj) : error LNK2005: "public: class boost::program_options::options_description_easy_init & __thiscall boost::program_options::options_description_easy_init::operator()(char const *,class boost::program_options::value_semantic const *,char const *)" (??Roptions_description_easy_init@program_options@boost@@QAEAAV012@PBDPBVvalue_semantic@12@0@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(options_description.obj) : error LNK2005: "public: class boost::program_options::options_description & __thiscall boost::program_options::options_description::add(class boost::program_options::options_description const &)" (?add@options_description@program_options@boost@@QAEAAV123@ABV123@@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. libboost_program_options-vc80-mt-1_35.lib(convert.obj) : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl boost::program_options::to_internal(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?to_internal@program_options@boost@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV34@@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert. using the linker options: /O2 /Ob2 /I "C:\Cpp\boost_1_35_0" /I ... /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "BOOST_ENABLE_ASSERT_HANDLER=1" /D "QT_DLL" /D "QT_GUI_LIB" /D "QT_CORE_LIB" /D "QT_NO_DEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /FD /EHsc /MD /Fo"eda.dir\Release\\" /Fd"D:/work/build/Release/eda.pdb" /W3 /nologo /c /TP /errorReport:prompt Any ideas what happened here? Thanks, Olaf

maybe also of interest the compiler options: /O2 /Ob2 /I "C:\Cpp\boost_1_35_0" /I ... /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "BOOST_ENABLE_ASSERT_HANDLER=1" /D "QT_DLL" /D "QT_GUI_LIB" /D "QT_CORE_LIB" /D "QT_NO_DEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /FD /EHsc /MD /Fo"eda.dir\Release\\" /Fd"D:/work/eda/build/Release/eda.pdb" /W3 /nologo /c /TP /errorReport:prompt

Hi! What is project organization? Usually this means that you use multiple dlls, which export same symbols. Regards, Ovanes On Wed, Sep 3, 2008 at 1:14 PM, Olaf Peter <ope-devel@gmx.de> wrote:
maybe also of interest the compiler options:
/O2 /Ob2 /I "C:\Cpp\boost_1_35_0" /I ... /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "BOOST_ENABLE_ASSERT_HANDLER=1" /D "QT_DLL" /D "QT_GUI_LIB" /D "QT_CORE_LIB" /D "QT_NO_DEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /FD /EHsc /MD /Fo"eda.dir\Release\\" /Fd"D:/work/eda/build/Release/eda.pdb" /W3 /nologo /c /TP /errorReport:prompt

Hi Olaf ! An'n Mittwoch 03 September 2008 hett Olaf Peter schreven:
Hi,
I've got the linker error LNK2005 (http://msdn.microsoft.com/en-us/library/72zdcz6f(VS.80).aspx) using MSVC80 (Studio 2005):
libboost_program_options-vc80-mt-1_35.lib(value_semantic.obj) : error LNK2005: ist bereits in
boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert.
You're linking against both static and shared library at the same time.Can't work.
using the linker options:
/O2 /Ob2 /I "C:\Cpp\boost_1_35_0" /I ... /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "BOOST_ENABLE_ASSERT_HANDLER=1" /D "QT_DLL" /D "QT_GUI_LIB" /D "QT_CORE_LIB" /D "QT_NO_DEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /FD /EHsc /MD /Fo"eda.dir\Release\\" /Fd"D:/work/build/Release/eda.pdb" /W3 /nologo /c /TP /errorReport:prompt
Any ideas what happened here?
CMake running wild ? Look at FindBoost.cmake what went wrong. And most probably disabled autolinking or add BOOST_ALL_DYN_LINK if you want shared libs. Take a look at the getting started guide for more tips. Yours, Jürgen -- * Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für * voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH * fax : ++49 511 262926 99 ! Lister Straße 15 * juergen.hunold@ivembh.de ! www.ivembh.de * * Geschäftsführer: ! Sitz des Unternehmens: Hannover * Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965 * PD Dr.-Ing. Alfons Radtke !

Olaf Peter wrote:
Hi,
I've got the linker error LNK2005 (http://msdn.microsoft.com/en-us/library/72zdcz6f(VS.80).aspx) using MSVC80 (Studio 2005):
libboost_program_options-vc80-mt-1_35.lib(value_semantic.obj) : error LNK2005: "public: __thiscall boost::program_options::invalid_option_value::invalid_option_value(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0invalid_option_value@program_options@boost@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V $allocator@D@2@@std@@@Z) ist bereits in boost_program_options-vc80-mt-1_35.lib(boost_program_options-vc80-mt-1_35.dll) definiert.
BTW, it's better to use English locale so that your errors message are clear to everybody. It appears that one part of your applications links to libboost_program_options-vc80-mt-1_35.lib (static library) while another links to boost_program_options-vc80-mt-1_35.lib (import lib). The only reason I can imagine for that is that parts of your applications are built with different settings -- in particular BOOST_ALL_DYN_LINK macro. Try cleaning everything, making sure that macro is set the the same value everywhere, and try again. - Volodya

Thanks to all answers, I'm using really cmake. Obviously I have to go more into the deep since the cmake macro does a bad job here. Define BOOST_ALL_DYN_LINK works for this time since I want static linkage. <OT> How can I set the English locale for MSVC compiler cl.exe inside VS IDE? which should be in current locale. </OT> Thanks, Olaf

BOOST_ALL_DYN_LINK is for dynamic linking But what is the macro for All Static linking ? 2008/9/4 Olaf Peter <ope-devel@gmx.de>
Thanks to all answers, I'm using really cmake. Obviously I have to go more into the deep since the cmake macro does a bad job here. Define BOOST_ALL_DYN_LINK works for this time since I want static linkage.
<OT> How can I set the English locale for MSVC compiler cl.exe inside VS IDE? which should be in current locale. </OT>
Thanks, Olaf _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

I've used BOOST_ALL_STATIC_LINK I've declared my path to the static libs, And also, I have the errors : Error 2 error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@ @QAEAAV01@ABV01@@Z) already defined in libboost_filesystem-vc80-mt-sgd-1_35.lib(operations.obj) msvcprtd.lib [...] And what's more this error : Error 26 fatal error LNK1104: cannot open file 'libboost_filesystem-vc80-mt-gd-1_35.lib' makePatch Why is it still searching a dynamic lib ??? nevermind dynamic libs !!! I have only 7 files in my program, it's not complicated to check all. What is the boost concept of autolink ? My static libs have been installed by the exe distributed with all libs (static dyn, debug not debg.. and so on) 2008/9/4 Olaf Peter <ope-devel@gmx.de>
Thanks to all answers, I'm using really cmake. Obviously I have to go more into the deep since the cmake macro does a bad job here. Define BOOST_ALL_DYN_LINK works for this time since I want static linkage.
<OT> How can I set the English locale for MSVC compiler cl.exe inside VS IDE? which should be in current locale. </OT>
Thanks, Olaf _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (5)
-
Germain BARRET
-
Jürgen Hunold
-
Olaf Peter
-
Ovanes Markarian
-
Vladimir Prus