Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Linking Opl with a MTA VS2008 C++ project

    Posted Mon February 07, 2011 10:12 AM

    Originally posted by: Frank_da


    Hi,

    as a newbie I am not very experienced in C++ and linking issues, though I hope the description of my problem is sufficient to find a solution:

    What I have:
    • latest CPLEX 12.2 + fixpack12.2.2 Academic Initiative version installed
    • MS VS C++ 2008
    • an existing static (libcmt.lib)C++ project that I want to use OPL & CPLEX with. I need opl to read in a .mod file from the existing project (and not getting my hands dirty on building the Columns/rows manually in CPLEX)

    What works just fine:
    • running the examples in ..\opl\examples\opl_interfaces\cpp\x86_windows_vs2008\stat_mda
    • building a separate "Demo" Project that I use to test my C++ integration. This project is linked against the msvcrt.lib (mda) and runs just fine
    • running the existing C++ Project with the (mta) CPLEX libs is also fine

    The problem:
    • integrating OPL into the existing C++ project (that is in the MTA format)

    I cant find a MTA format for the OPL libs as described in the OPL interfaces manual under "Using the C++ interfaces"

    Can anyone help me on how to use OPL with an C++ project that is linked against libcmt.lib in VS 2008?

    The errors I get when I try to use OPL libs with the "MTA" project and headers are the following:

    2>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::_Mutex::_Lock(void)" (?_Lock@_Mutex@std@@QAEXXZ) ist bereits in libcpmtd.lib(xmutex.obj) definiert.
    2>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: void __thiscall std::_Mutex::_Unlock(void)" (?_Unlock@_Mutex@std@@QAEXXZ) ist bereits in libcpmtd.lib(xmutex.obj) definiert.
    2>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) ist bereits in main.obj definiert.
    2>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) ist bereits in bs.lib(bs_platform.obj) definiert.
    2>msvcprt.lib(MSVCP90.dll) : error LNK2005: "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) ist bereits in libcpmtd.lib(uncaught.obj) definiert.

    and many more of the same type and

    MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strchr ist bereits in LIBCMTD.lib(strchr.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strstr ist bereits in LIBCMTD.lib(strstr.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _sprintf ist bereits in LIBCMTD.lib(sprintf.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free ist bereits in LIBCMTD.lib(dbgfree.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc ist bereits in LIBCMTD.lib(dbgmalloc.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _realloc ist bereits in LIBCMTD.lib(dbgrealloc.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strcpy_s ist bereits in LIBCMTD.lib(strcpy_s.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strncpy_s ist bereits in LIBCMTD.lib(strncpy_s.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _setlocale ist bereits in LIBCMTD.lib(setlocal.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _clock ist bereits in LIBCMTD.lib(clock.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strtol ist bereits in LIBCMTD.lib(strtol.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __errno ist bereits in LIBCMTD.lib(dosmap.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strncmp ist bereits in LIBCMTD.lib(strncmp.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strtod ist bereits in LIBCMTD.lib(strtod.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _atof ist bereits in LIBCMTD.lib(atof.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv ist bereits in LIBCMTD.lib(getenv.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) ist bereits in LIBCMTD.lib(stdexcpt.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) ist bereits in LIBCMTD.lib(stdexcpt.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) ist bereits in LIBCMTD.lib(stdexcpt.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) ist bereits in LIBCMTD.lib(stdexcpt.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _atoi ist bereits in LIBCMTD.lib(atox.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _ceil ist bereits in LIBCMTD.lib(_ceil_pentium4_.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __controlfp ist bereits in LIBCMTD.lib(_ieee87_.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __isnan ist bereits in LIBCMTD.lib(_ieeemisc_.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __localtime64 ist bereits in LIBCMTD.lib(loctim64.obj) definiert.
    2>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __time64 ist bereits in LIBCMTD.lib(time64.obj) definiert.

    In total there are 170 LNK2005 errors.

    Thanks in advance!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Linking Opl with a MTA VS2008 C++ project

    Posted Mon February 07, 2011 12:07 PM

    Originally posted by: SystemAdmin


    The errors are basically from mixing dynamic (MSVCRT) and static debug (LIBCMTD) version of CRT. OPL libraries are indeed built with dynamic version of CRT and unlike CPLEX there is no static counterpart.

    So, question is can you link your project to dynamic CRT? If you are using other third party library that is built using LIBCMT then you may want to check if a dynamic version is available from them.

    You may also try to force multiple version of libraries using /FORCE:MULTIPLE as described here:
    http://msdn.microsoft.com/en-us/library/70abkas3%28v=VS.90%29.aspx

    However, that would not be a supported configuration and recommendation would be to link your project using /MD option.

    Regards,
    Faisal
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Linking Opl with a MTA VS2008 C++ project

    Posted Tue February 08, 2011 10:23 AM

    Originally posted by: Frank_da


    I tried the /MD option for my existing project and fortunately everything works fine.

    Nevertheless I would prefer the OPL objects to be linked with the static CRT version.

    Is there any information available if a static version of OPL is going to be released? Since CPLEX is provided as MTA and MDA why is OPL not?

    Thanks in advance! Fast & good support here!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer