这是从:技术文档中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 ortest.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
.
- Start Microsoft Visual Studio 2008.
- 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.
test
, with a single project,test
. You can see the contents of the solution by selecting Solution Explorer in the View menu. - Now you must add your source file to the project. From the Project menu, choose Add Existing Item...
- Move to the folder
<MYAPPDIR>
and selecttest.cpp
ortest.c
. - Click Open.
- Move to the folder
- 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.
- In the Additional Include Directories field, add the directories:
- Select Preprocessor:
- Add
IL_STD
to the Preprocessor Definitions field. This defines the macro IL_STD which is needed to use the STL.
- Add
- Select Code Generation:
- Set Runtime Library to Multi-threaded (/MT).
- 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
- Select General:
- 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.
- Finally, to build the project, from the Build menu, select Build Solution
test.exe
is
<MYAPPDIR>\test\Release\test.exe
.