Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Linking Error (only with Network)  (Read 3143 times)

0 Members and 1 Guest are viewing this topic.

wademcgillis

  • Newbie
  • *
  • Posts: 36
    • View Profile
Linking Error (only with Network)
« on: June 27, 2012, 09:58:20 pm »
Hello. I'm using the SFML 2.0 RC static libraries, with everything set to /MD

This code compiles fine. No linking issues.
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#pragma comment(lib,"sfml-network-s.lib")
#pragma comment(lib,"sfml-graphics-s.lib")
#pragma comment(lib,"sfml-window-s.lib")
#pragma comment(lib,"sfml-system-s.lib")

int main()
{
        //sf::Http h("http://games.wademcgillis.com/astronot/update.php?action=md5&type=win",80);
        sf::Image bob;
        return 0;
}
 

This code causes the linker to freak out:
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#pragma comment(lib,"sfml-network-s.lib")
#pragma comment(lib,"sfml-graphics-s.lib")
#pragma comment(lib,"sfml-window-s.lib")
#pragma comment(lib,"sfml-system-s.lib")

int main()
{
        sf::Http h("http://games.wademcgillis.com/astronot/update.php?action=md5&type=win",80);
        sf::Image bob;
        return 0;
}
 

Quote
Compiling...
main.cpp
Linking...
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::basic_string,class std::allocator >(class std::basic_string,class std::allocator > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in libcpmt.lib(string.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in main.obj
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_string,class std::allocator >::push_back(char)" (?push_back@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXD@Z) already defined in sfml-system-s.lib(String.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_ostream > & __thiscall std::basic_ostream >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in sfml-graphics-s.lib(Image.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_ostream >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in sfml-graphics-s.lib(Image.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_ios >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in sfml-graphics-s.lib(Image.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf >::sputn(char const *,int)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z) already defined in sfml-graphics-s.lib(Image.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in sfml-graphics-s.lib(Image.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::_String_iterator,class std::allocator > __thiscall std::basic_string,class std::allocator >::end(void)" (?end@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE?AV?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ) already defined in sfml-graphics-s.lib(ImageLoader.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::_String_iterator,class std::allocator > __thiscall std::basic_string,class std::allocator >::begin(void)" (?begin@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE?AV?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ) already defined in sfml-graphics-s.lib(ImageLoader.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "protected: void __thiscall std::basic_string,class std::allocator >::_Tidy(bool,unsigned int)" (?_Tidy@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEX_NI@Z) already defined in main.obj
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::basic_string,class std::allocator >::reserve(unsigned int)" (?reserve@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXI@Z) already defined in sfml-system-s.lib(String.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z) already defined in main.obj
msvcprt.lib(MSVCP90.dll) : error LNK2005: "bool __cdecl std::operator==,class std::allocator >(class std::basic_string,class std::allocator > const &,char const *)" (??$?8DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@PBD@Z) already defined in sfml-graphics-s.lib(ImageLoader.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > __thiscall std::basic_string,class std::allocator >::substr(unsigned int,unsigned int)const " (?substr@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV12@II@Z) already defined in sfml-graphics-s.lib(ImageLoader.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::allocator::deallocate(char *,unsigned int)" (?deallocate@?$allocator@D@std@@QAEXPADI@Z) already defined in main.obj
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::basic_string,class std::allocator >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in main.obj
msvcprt.lib(MSVCP90.dll) : error LNK2005: "class std::basic_ostream > & __cdecl std::operator<<,class std::allocator >(class std::basic_ostream > &,class std::basic_string,class std::allocator > const &)" (??$?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z) already defined in sfml-graphics-s.lib(ImageLoader.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::basic_string,class std::allocator >(void)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in sfml-system-s.lib(Err.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_ostream > & __thiscall std::basic_ostream >::operator<<(class std::basic_ostream > & (__cdecl*)(class std::basic_ostream > &))" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z) already defined in sfml-graphics-s.lib(Image.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "class std::basic_ostream > & __cdecl std::endl(class std::basic_ostream > &)" (?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z) already defined in sfml-graphics-s.lib(Image.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: char * __thiscall std::allocator::allocate(unsigned int)" (?allocate@?$allocator@D@std@@QAEPADI@Z) already defined in main.obj
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(char const *,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBDI@Z) already defined in main.obj
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::_String_const_iterator,class std::allocator > __thiscall std::basic_string,class std::allocator >::end(void)const " (?end@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$_String_const_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ) already defined in sfml-system-s.lib(String.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::_String_const_iterator,class std::allocator > __thiscall std::basic_string,class std::allocator >::begin(void)const " (?begin@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$_String_const_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ) already defined in sfml-system-s.lib(String.obj)
msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in sfml-system-s.lib(Err.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMT.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in LIBCMT.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) already defined in LIBCMT.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: __invalid_parameter_noinfo already defined in LIBCMT.lib(invarg.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMT.lib(stdexcpt.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _tolower already defined in LIBCMT.lib(tolower.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isdigit already defined in LIBCMT.lib(_ctype.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _memmove_s already defined in LIBCMT.lib(memmove_s.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _abort already defined in LIBCMT.lib(abort.obj)
libcpmt.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl*)(void))" (?_AtModuleExit@@YAXP6AXXZ@Z) already defined in msvcprt.lib(locale0_implib.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(MSVCP90.dll)
libcpmt.lib(locale0.obj) : error LNK2005: __Fac_tidy already defined in msvcprt.lib(locale0_implib.obj)
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(locale0_implib.obj)
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(MSVCP90.dll)
libcpmt.lib(locale0.obj) : error LNK2005: "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in msvcprt.lib(MSVCP90.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(MSVCP90.dll)
libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string,class std::allocator > const &)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) already defined in msvcprt.lib(MSVCP90.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(MSVCP90.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(MSVCP90.dll)
libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprt.lib(MSVCP90.dll)
libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprt.lib(MSVCP90.dll)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
E:\shit\Release\shit.exe : fatal error LNK1169: one or more multiply defined symbols found

The problem is that I can't compile my project while using sfml-network, and any use of /NODEFAULTLIB causes the linker to complain that things are missing.

How do I fix this?

Edit:
I should also add that leaving everything as /MD causes linking issues with the first code bit.
« Last Edit: June 27, 2012, 10:02:29 pm by wademcgillis »

cpp_noob

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Linking Error (only with Network)
« Reply #1 on: April 19, 2020, 09:03:40 am »
I have the same problem!

Souren

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Linking Error (only with Network)
« Reply #2 on: April 23, 2020, 01:59:52 am »
I might have the same problem too.. https://en.sfml-dev.org/forums/index.php?topic=27152.0

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Linking Error (only with Network)
« Reply #3 on: April 23, 2020, 08:32:07 am »
This is not the same problem at all. This is an 8 year old linker issue with the compiler's standard libraries; there's no CMake involved and SFML is linked directly (and statically).
Laurent Gomila - SFML developer

 

anything