Google c++ test framework is giving linking errors

2,004 views
Skip to first unread message

rajeev

unread,
Oct 28, 2011, 2:36:49 AM10/28/11
to Google C++ Testing Framework, rajeev_...@mcafee.com, rajeev...@gmail.com
Dear Group,

I am testing SPIPE code(protocol for communication) by using Google
test framework. But I am getting lot of linking errors regarding some
conflict among libraries. If I am building only SPIPE code then it is
working fine. I am using visual studio 2005 for building code.

I am using run time library as Multi threaded DLL.
The linking errors are as below:

------ Build started: Project: spipePackagerUT, Configuration: Release
Win32 ------
Compiling...
GoogleTest.cpp
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(81) : while compiling class template member
function 'boost::posix_time::ptime
boost::date_time::microsec_clock<time_type>::create_time(boost::date_time::microsec_clock<time_type>::time_converter)'
with
[
time_type=boost::posix_time::ptime
]
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/thread/
thread_time.hpp(20) : see reference to class template instantiation
'boost::date_time::microsec_clock<time_type>' being compiled
with
[
time_type=boost::posix_time::ptime
]
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
spipePackagerContext.cpp
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(81) : while compiling class template member
function 'boost::posix_time::ptime
boost::date_time::microsec_clock<time_type>::create_time(boost::date_time::microsec_clock<time_type>::time_converter)'
with
[
time_type=boost::posix_time::ptime
]
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/thread/
thread_time.hpp(20) : see reference to class template instantiation
'boost::date_time::microsec_clock<time_type>' being compiled
with
[
time_type=boost::posix_time::ptime
]
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
spipePackager.cpp
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(81) : while compiling class template member
function 'boost::posix_time::ptime
boost::date_time::microsec_clock<time_type>::create_time(boost::date_time::microsec_clock<time_type>::time_converter)'
with
[
time_type=boost::posix_time::ptime
]
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/thread/
thread_time.hpp(20) : see reference to class template instantiation
'boost::date_time::microsec_clock<time_type>' being compiled
with
[
time_type=boost::posix_time::ptime
]
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
E:\SVN\projects\boost_masdk\boost\boost_1_39_0\boost/date_time/
microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion
from 'int' to 'unsigned short', possible loss of data
Generating Code...
Linking...
msvcprt.lib(MSVCP80.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 gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.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 gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.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 gtest.lib(gtest-
all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: void __thiscall
std::locale::facet::_Incref(void)" (?_Incref@facet@locale@std@@QAEXXZ)
already defined in gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: class
std::locale::facet const * __thiscall std::locale::_Getfacet(unsigned
int)const " (?_Getfacet@locale@std@@QBEPBVfacet@12@I@Z) already
defined in gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: class
std::basic_ostream<char,struct std::char_traits<char> > & __thiscall
std::basic_ostream<char,struct std::char_traits<char>
>::flush(void)" (?flush@?$basic_ostream@DU?
$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: void __thiscall
std::basic_ostream<char,struct std::char_traits<char>
>::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?
$char_traits@D@std@@@std@@QAEXXZ) already defined in gtest.lib(gtest-
all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: void __thiscall
std::basic_ios<char,struct std::char_traits<char>
>::setstate(int,bool)" (?setstate@?$basic_ios@DU?
$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: int __thiscall
std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char
const *,int)" (?sputn@?$basic_streambuf@DU?
$char_traits@D@std@@@std@@QAEHPBDH@Z) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: int __thiscall
std::basic_streambuf<char,struct std::char_traits<char>
>::sputc(char)" (?sputc@?$basic_streambuf@DU?
$char_traits@D@std@@@std@@QAEHD@Z) already defined in gtest.lib(gtest-
all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall
std::locale::~locale(void)" (??1locale@std@@QAE@XZ) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: class std::locale
__thiscall std::ios_base::getloc(void)const " (?
getloc@ios_base@std@@QBE?AVlocale@2@XZ) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: void __thiscall
std::basic_stringstream<char,struct std::char_traits<char>,class
std::allocator<char> >::`vbase destructor'(void)" (??_D?
$basic_stringstream@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@QAEXXZ) already defined in gtest.lib(gtest-
all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > __thiscall std::basic_stringstream<char,struct
std::char_traits<char>,class std::allocator<char> >::str(void)const
" (?str@?$basic_stringstream@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@2@XZ) already defined in gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall
std::basic_stringstream<char,struct std::char_traits<char>,class
std::allocator<char> >::basic_stringstream<char,struct
std::char_traits<char>,class std::allocator<char> >(int)" (??0?
$basic_stringstream@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@QAE@H@Z) already defined in gtest.lib(gtest-
all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: class
std::basic_ostream<char,struct std::char_traits<char> > & __thiscall
std::basic_ostream<char,struct std::char_traits<char>
>::operator<<(unsigned long)" (??6?$basic_ostream@DU?
$char_traits@D@std@@@std@@QAEAAV01@K@Z) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: class
std::basic_ostream<char,struct std::char_traits<char> > & __thiscall
std::basic_ostream<char,struct std::char_traits<char>
>::operator<<(class std::basic_ostream<char,struct
std::char_traits<char> > & (__cdecl*)(class
std::basic_ostream<char,struct std::char_traits<char> > &))" (??6?
$basic_ostream@DU?
$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z) already
defined in gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "class
std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
std::endl(class std::basic_ostream<char,struct std::char_traits<char>
> &)" (?endl@std@@YAAAV?$basic_ostream@DU?
$char_traits@D@std@@@1@AAV21@@Z) already defined in gtest.lib(gtest-
all.obj)
msvcprt.lib(MSVCP80.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)" (??0?
$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ)
already defined in gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: class
std::basic_ostream<char,struct std::char_traits<char> > & __thiscall
std::basic_ostream<char,struct std::char_traits<char> >::write(char
const *,int)" (?write@?$basic_ostream@DU?
$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : 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> >::append(char const
*,unsigned int)" (?append@?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@QAEAAV12@PBDI@Z) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: void __thiscall
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >::reserve(unsigned int)" (?reserve@?
$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXI@Z)
already defined in gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : 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 gtest.lib(gtest-all.obj)
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
msvcprt.lib(MSVCP80.dll)
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 msvcprt.lib(MSVCP80.dll)
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
msvcprt.lib(MSVCP80.dll)
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
msvcprt.lib(MSVCP80.dll)
libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl
std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,char const *)" (?
_Locinfo_ctor@_Locinfo@std@@SAXPAV12@PBD@Z) already defined in
msvcprt.lib(MSVCP80.dll)
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
msvcprt.lib(MSVCP80.dll)
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
msvcprt.lib(MSVCP80.dll)
libcpmt.lib(wcerr.obj) : error LNK2005: "public: wchar_t __thiscall
std::ctype<wchar_t>::widen(char)const " (?widen@?
$ctype@_W@std@@QBE_WD@Z) already defined in msvcprt.lib(MSVCP80.dll)
libcpmt.lib(wcerr.obj) : error LNK2005: "public: static unsigned int
__cdecl std::ctype<wchar_t>::_Getcat(class std::locale::facet const *
*)" (?_Getcat@?$ctype@_W@std@@SAIPAPBVfacet@locale@2@@Z) already
defined in msvcprt.lib(MSVCP80.dll)
libcpmt.lib(wcerr.obj) : error LNK2005: "public: void __thiscall
std::basic_ios<wchar_t,struct std::char_traits<wchar_t>
>::setstate(int,bool)" (?setstate@?$basic_ios@_WU?
$char_traits@_W@std@@@std@@QAEXH_N@Z) already defined in
msvcprt.lib(MSVCP80.dll)
libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall
std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined
in msvcprt.lib(MSVCP80.dll)
libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall
std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined
in msvcprt.lib(MSVCP80.dll)
libcpmt.lib(xwctomb.obj) : error LNK2005: __Getcvt already defined in
msvcprt.lib(MSVCP80.dll)
LIBCMT.lib(setlocal.obj) : error LNK2005: __configthreadlocale already
defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(_file.obj) : error LNK2005: ___iob_func already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already
defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter_noinfo
already defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(dosmap.obj) : error LNK2005: __errno already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(osfinfo.obj) : error LNK2005: __open_osfhandle already
defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(_wctype.obj) : error LNK2005: _iswspace already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(tidtable.obj) : error LNK2005: __encode_pointer already
defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(tidtable.obj) : error LNK2005: __decode_pointer already
defined in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(close.obj) : error LNK2005: __close already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(lconv.obj) : error LNK2005: _localeconv already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(fflush.obj) : error LNK2005: _fflush already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined
in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined
in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined
in MSVCRT.lib(crtexe.obj)
LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined
in MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(stricmp.obj) : error LNK2005: __stricmp already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in
MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in
MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in
MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in
MSVCRT.lib(cinitexe.obj)
LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl
terminate(void)" (?terminate@@YAXXZ) already defined in
MSVCRT.lib(MSVCR80.dll)
LIBCMT.lib(getenv.obj) : error LNK2005: _getenv already defined in
MSVCRT.lib(MSVCR80.dll)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: wchar_t __thiscall
std::basic_ios<wchar_t,struct std::char_traits<wchar_t>
>::widen(char)const " (?widen@?$basic_ios@_WU?
$char_traits@_W@std@@@std@@QBE_WD@Z) already defined in
libcpmt.lib(wcerr.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: __thiscall
std::codecvt<wchar_t,char,int>::codecvt<wchar_t,char,int>(unsigned
int)" (??0?$codecvt@_WDH@std@@QAE@I@Z) already defined in
libcpmt.lib(wcerr.obj)
msvcprt.lib(MSVCP80.dll) : 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=(char
const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?
$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in
gtest.lib(gtest-all.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: static unsigned int
__cdecl std::codecvt<wchar_t,char,int>::_Getcat(class
std::locale::facet const * *)" (?_Getcat@?
$codecvt@_WDH@std@@SAIPAPBVfacet@locale@2@@Z) already defined in
libcpmt.lib(wcerr.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "protected: virtual
__thiscall std::locale::_Locimp::~_Locimp(void)" (??
1_Locimp@locale@std@@MAE@XZ) already defined in
libcpmt.lib(locale0.obj)
msvcprt.lib(MSVCP80.dll) : error LNK2005: "public: static class
std::locale const & __cdecl std::locale::classic(void)" (?
classic@locale@std@@SAABV12@XZ) already defined in
libcpmt.lib(locale0.obj)
Creating library ..\..\..\..\win\Release/spipePackagerUT.lib and
object ..\..\..\..\win\Release/spipePackagerUT.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of
other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of
other libs; use /NODEFAULTLIB:library
..\..\..\..\win\Release/spipePackagerUT.exe : fatal error LNK1169: one
or more multiply defined symbols found
Build log was saved at "file://e:\SVN\MSA\trunk\common\spipePackager\ut
\win32\Release\BuildLog.htm"
spipePackagerUT - 71 error(s), 11 warning(s)



The above errors are due to use of google test framework. SPIPE code
alone is working fine.
Could any one suggest for solving above issue?

Thanks
Rajeev

Greg Miller

unread,
Oct 28, 2011, 2:17:11 PM10/28/11
to rajeev, Google C++ Testing Framework, rajeev_...@mcafee.com
Hi, Rajeev.

Make sure you're building the gmock library correctly and that its linkage settings are what you expect. In particular, you probably need to make sure gmock is built as a Multi-threaded DLL.

HTH,

Greg

rajeev varshney

unread,
Oct 30, 2011, 3:41:27 AM10/30/11
to Greg Miller, Google C++ Testing Framework, rajeev_...@mcafee.com
Hi Greg,

Great!! It solved my problems..

Thanks
Rajeev

Reply all
Reply to author
Forward
0 new messages