Cplex 在Visual studio 中的使用配置

这是从:技术文档中copy 过来的,详细请参看manual


Building Your Own Project which Links with CPLEX

Note:
The information below applies to the Visual C++ 2008 multi-threaded STL library. If you use another version of the library, set the  Runtime Library  option to match the library version. If you use Visual Studio 2010, the instructions below should apply, except that x86_windows_vs2008  should be replaced with  x86_windows_vs2010  whenever a path name is specified.

Let's assume that you want to build a target named test.exe and have:

  • a source file named test.cpp which uses Concert Technology or test.c which uses the C API of the CPLEX Callable Library;
  • a folder where this file is located and which, for the sake of simplicity, we'll refer to as <MYAPPDIR>.

One way to achieve that is to create a project named test.vcproj as described here. Be aware that the order of instructions is important. Note that project files for VS2010 have the extension vcxproj.

  1. Start Microsoft Visual Studio 2008. 

  2. The first step is to build the test.sln solution.
    From the File menu, select New->, and then Project....

    The New Project dialog box appears.

    • In the Project types pane, select Visual C++ and Win32.
    • In the Templates pane, select the Win32 Console Application icon.
    • Fill in the project name (test).
    • If necessary, correct the location of the project (to <MYAPPDIR>)
    • Click OK

    When the Win32 Application Wizard appears...

    • Click on Application Settings.
    • Select Console Application as Application type.
    • Make sure that Empty project is checked in Additional Options.
    • Click Finish.

    This creates a solution, test, with a single project, test. You can see the contents of the solution by selecting Solution Explorer in the View menu.

  3. Now you must add your source file to the project. From the Project menu, choose Add Existing Item...
    • Move to the folder <MYAPPDIR> and select test.cpp or test.c.
    • Click Open.

  4. Next, you have to set some options so that the project knows where to find the CPLEX and Concert include files and the CPLEX and Concert libraries.

    From the Project menu, choose Properties.
    The test Property Pages dialog box appears.

    In the Configuration drop-down list, select Release.

    Select C/C++ in the Configuration Properties tree.

    • Select General:
      • In the Additional Include Directories field, add the directories:
        • <CPLEXDIR>\include.
        • <CONCERTDIR>\include.
      • For Debug Information Format, choose Disabled (/Zd).
      • Choose No for Detect 64-bit Portability Issues. Note that these settings are not available in the Visual Studio 2010 IDE and can be omitted.

    • Select Preprocessor:
      • Add IL_STD to the Preprocessor Definitions field. This defines the macro IL_STD which is needed to use the STL.

    • Select Code Generation:
      • Set Runtime Library to Multi-threaded (/MT).

    Select Linker in the Configuration Properties tree.
    • Select General and then select Additional Library Directoriess. Add the files:
      • <CPLEXDIR>\lib\x86_windows_vs2008\stat_mta
      • <CONCERTDIR>\lib\x86_windows_vs2008\stat_mta
    • Select Input and then select Additional Dependencies. Add the files:
      • cplex124.lib
      • ilocplex.lib
      • concert.lib
      The latter two are only necessary if you are using Concert Technology.

    Click OK to close the test Property Pages dialog box.

  5. Next, you have to set the default project configuration.

    From the Build menu, select Configuration Manager...

    • Select Release in the Active Solution Configuration drop-down list.
    • Click Close.

  6. Finally, to build the project, from the Build menu, select Build Solution
After completion of the compiling and linking process, the target is created. The full path of the  test.exe  is  <MYAPPDIR>\test\Release\test.exe .

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值