Discussion:
[program_options] linker error LNK2005 (symbol already defined in object)
Olaf Peter
2008-09-03 11:08:48 UTC
Permalink
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 &)"
(??***@program_options@boost@@***@ABV?$***@DU?$***@D@std@@V?$***@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 "
(?***@validation_error@***@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)"
(?***@program_options@boost@@***@2@ABV?$***@V?$***@DU?$***@D@std@@V?$***@D@2@@std@@V?$***@V?$***@DU?$***@D@std@@V?$***@D@2@@std@@@2@@std@@PAV?$***@DU?$***@D@std@@V?$***@D@2@@***@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@?$***@D@***@boost@@***@3@ABV?$***@V?$***@DU?$***@D@std@@V?$***@D@2@@std@@V?$***@V?$***@DU?$***@D@std@@V?$***@D@2@@std@@@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(options_description.obj) :
error LNK2005: "public: class
boost::program_options::options_description_easy_init __thiscall
boost::program_options::options_description::add_options(void)"
(?***@options_description@***@boost@@QAE?***@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 &)"
(??***@boost@@YAAAV?$***@DU?$***@D@std@@@std@@***@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)" (??***@program_options@boost@@***@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)"
(??***@program_options@boost@@***@ABV?$***@DU?$***@D@std@@V?$***@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(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 *)"
(??***@program_options@boost@@***@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
*)"
(??***@program_options@boost@@***@PBDPBVvalue_semantic@***@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 &)"
(?***@options_description@***@boost@@***@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 &)"
(?***@program_options@boost@@YA?AV?$***@DU?$***@D@std@@V?$***@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
Olaf Peter
2008-09-03 11:14:11 UTC
Permalink
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
Ovanes Markarian
2008-09-03 11:39:46 UTC
Permalink
Hi!

What is project organization? Usually this means that you use multiple dlls,
which export same symbols.


Regards,
Ovanes
Post by Olaf Peter
/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
Jürgen Hunold
2008-09-03 11:24:50 UTC
Permalink
Hi Olaf !
Post by Olaf Peter
Hi,
I've got the linker error LNK2005
(http://msdn.microsoft.com/en-us/library/72zdcz6f(VS.80).aspx) using
libboost_program_options-vc80-mt-1_35.lib(value_semantic.obj) : error
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.
Post by Olaf Peter
/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
* ***@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 !
Vladimir Prus
2008-09-03 11:26:10 UTC
Permalink
Post by Olaf Peter
Hi,
I've got the linker error LNK2005
(http://msdn.microsoft.com/en-us/library/72zdcz6f(VS.80).aspx) using
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 &)"
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
Olaf Peter
2008-09-04 06:21:17 UTC
Permalink
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
Germain BARRET
2008-10-01 07:40:01 UTC
Permalink
BOOST_ALL_DYN_LINK is for dynamic linking
But what is the macro for All Static linking ?
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
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Germain BARRET
2008-10-01 07:47:28 UTC
Permalink
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?$***@DU?$***@D@std@@V?$***@D@2@@std@
@***@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)
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
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...