[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

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
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
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
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
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