Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  C++ Errors related to 'LNK2005'

    Posted Mon March 21, 2011 08:23 PM

    Originally posted by: LuisdelaTorre


    I'm working on a program using Concert and getting compilation (linking?) errors I don't understand. I have:

    Windows 7 64-bit Pro
    Visual Studio 2008 - Version 9.0.30729.1 SP

    I have followed the instructions in the <CPLEXDIR>/c_cpp.html to set up VS2008 for use with Concert.

    I have tried compiling many of the example projects included with CPLEX. All of these work. I'm getting the errors shown below in my build log. What could be causing these errors?

    Thank you,

    Luis de la Torre

    1>------ Build started: Project: testProj, Configuration: Release Win32
    1>Compiling...
    1>testFile.cpp
    1>.\testFile.cpp(307) : warning C4244: '=' : conversion from 'IloNum' to 'IloInt', possible loss of data
    1>.\testFile.cpp(374) : warning C4244: '=' : conversion from 'IloNum' to 'IloInt', possible loss of data
    1>Linking...
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: virtual __thiscall std::basic_ostream<char,struct std::char_traits<char> >::~basic_ostream<char,struct std::char_traits<char> >(void)" (??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in libcpmt.lib(cout.obj)
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char> >::~basic_ios<char,struct std::char_traits<char> >(void)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in libcpmt.lib(cout.obj)
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: virtual __thiscall std::ios_base::~ios_base(void)" (??1ios_base@std@@UAE@XZ) already defined in libcpmt.lib(cout.obj)
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_ostream<char,struct std::char_traits<char> >::basic_ostream<char,struct std::char_traits<char> >(class std::basic_streambuf<char,struct std::char_traits<char> > *,bool)" (??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z) already defined in libcpmt.lib(cout.obj)
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::~basic_streambuf<char,struct std::char_traits<char> >(void)" (??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in libcpmt.lib(cout.obj)
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "protected: __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::basic_streambuf<char,struct std::char_traits<char> >(void)" (??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined in libcpmt.lib(cout.obj)
    1>msvcprt.lib(MSVCP90.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 ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::_Mutex::_Lock(void)" (?_Lock@_Mutex@std@@QAEXXZ) already defined in libcpmt.lib(xmutex.obj)
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::_Mutex::_Unlock(void)" (?_Unlock@_Mutex@std@@QAEXXZ) already defined in libcpmt.lib(xmutex.obj)
    1>msvcprt.lib(MSVCP90.dll) : 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 libcpmt.lib(ios.obj)
    1>msvcprt.lib(MSVCP90.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 ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.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 ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) already defined in libcpmt.lib(uncaught.obj)
    1>msvcprt.lib(MSVCP90.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 ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.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 ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.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 ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.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 ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.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<<(double)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z) already defined in ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.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 ilocplex.lib(ilocplex.obj)
    1>msvcprt.lib(MSVCP90.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<<(long)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z) already defined in ilocplex.lib(ilologicextr.obj)
    1>msvcprt.lib(MSVCP90.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<<(void const *)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z) already defined in ilocplex.lib(ilologicextr.obj)
    1>msvcprt.lib(MSVCP90.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<<(int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z) already defined in ilocplex.lib(ilocplex.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strcpy_s already defined in LIBCMT.lib(strcpy_s.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strncpy_s already defined in LIBCMT.lib(strncpy_s.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _setlocale already defined in LIBCMT.lib(setlocal.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free already defined in LIBCMT.lib(free.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strtol already defined in LIBCMT.lib(strtol.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __errno already defined in LIBCMT.lib(dosmap.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strncmp already defined in LIBCMT.lib(strncmp.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv already defined in LIBCMT.lib(getenv.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _ceil already defined in LIBCMT.lib(_ceil_pentium4_.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strcat_s already defined in LIBCMT.lib(strcat_s.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _vsprintf_s already defined in LIBCMT.lib(vsnprnc.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _isdigit already defined in LIBCMT.lib(_ctype.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _atoi already defined in LIBCMT.lib(atox.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __controlfp already defined in LIBCMT.lib(_ieee87_.obj)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __isnan already defined in LIBCMT.lib(_ieeemisc_.obj)
    1>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)
    1>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)
    1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __strdup already defined in LIBCMT.lib(strdup.obj)
    1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
    1>C:\Users\luis\Documents\My Dropbox\disaster_relief\cpp\testProj\Release\testProj.exe : fatal error LNK1169: one or more multiply defined symbols found
    1>Build log was saved at "file://c:\Users\luis\Documents\My Dropbox\cpp\testProj\testProj\Release\BuildLog.htm"
    1>singleStop - 41 error(s), 3 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: C++ Errors related to 'LNK2005'

    Posted Tue March 22, 2011 01:24 PM

    Originally posted by: GuangFeng


    For Code Generation, did you set Runtime Library to Multi-threaded (/MT)?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: C++ Errors related to 'LNK2005'

    Posted Tue March 22, 2011 01:29 PM

    Originally posted by: LuisdelaTorre


    Yes, and I have all other settings exactly as described in the c_cpp.html file.

    Thank you,

    Luis de la Torre
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: C++ Errors related to 'LNK2005'

    Posted Thu March 24, 2011 02:38 PM

    Originally posted by: GuangFeng


    The errors indicate you mixed multiple version of libraries, which should not happen if you followed the steps exactly without changing other settings.

    As a sanity check, you should try to compile the CPLEX ilo* examples to make sure CPLEX installation and compiler installation are fine. Then you can compare your project settings against the example projects to see whether you have missed something.
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: C++ Errors related to 'LNK2005'

    Posted Wed May 04, 2011 02:48 PM

    Originally posted by: LuisdelaTorre


    I'll mark this as answered - shortly after posting this, I figured out what was wrong, but I forgot this post existed until now and I don't remember what I did to correct the problem. I suspect that GuangFeng was right that I had some settings wrong.
    #CPLEXOptimizers
    #DecisionOptimization