next up previous contents index
Next: The AGD Server Up: Technical Information Previous: Unix Object Code Installation   Contents   Index


Windows Object Code Installation and Usage

This section describes the installation and usage of static libraries of AGD and LEDA with Microsoft Visual C++. The installation and usage of DLL's or static libraries for other compilers is similar. Please read the corresponding installation file in the AGD \Install \ subdirectory of the LEDA/AGD main directory.

Files and Directories

To compile and link your programs with AGD and LEDA, the LEDA/AGD main directory <LEDAADGD> should contain the following files and subdirectories:
AGD \Install \win32_lib.txt installation and usage of static libraries
AGD \Install \win32_dll.txt installation and usage of DLL's
incl \ the AGD and LEDA include directory
and at least one of the following library sets


Compiling and Linking Application Programs in Microsoft Visual Studio

To compile and link an application program using AGD and LEDA in Microsoft Visual Studio proceed as follows:
(1)
In the "File" menu of Visual Studio click on "New"
(2)
Choose "Win 32 Console Application" in "Projects", fill in the project name, and click "OK"
(3)
Choose "Empty Project" and click "Finish"
(4)
After clicking "OK" you have an empty project space
If you already have a source file prog.cpp:
(5)
Activate the file browser and add prog.cpp to the main folder of your project
(6)
In the "Workspace" of Visual Studio click on "Source Files" with the right mouse button, then click on "Add File to Folder" with the left mouse button
(7)
Double click on prog.cpp
If you want to enter a new source file:
(5')
In the "File" menu click on "New"
(6')
Choose "C++ Source File" in "Files", fill in the file name, and click "OK"
(7')
Enter your code
(8)
In the "Project" menu click on "Settings"
(9)
Choose "C/C++" and enter in "Project Options" the compiler flag you want to use. The default value is "/MLd", alternatives are "/ML", "/MD", "/MDd", "/MT", and "/MTd". Notice that you have to use the AGD and LEDA libraries that correspond to the chosen flag, e.g., with option "/MD" you must use libagd_md.lib, libl_md.lib, libg_md.lib, libp_md.lib, and libw_md.lib. Using another set of libraries with "/MD" could lead to serious linker errors.
(10)
Choose "Linker" and add the name of the AGD and LEDA libraries you want to use at the beginning of line "Object-/Library-Modules" as follows. I use <opt> to indicate the compiler option chosen in Step (9) (,i.e., <opt> is mld for "/MLd", ml for "/ML", ...).
(11)
Click "OK" to leave the "Settings"

(12)
In the "Extras" menu click on "Options"
(13)
Choose "Directories"
(14)
Choose "Include Files" in "Show Directories for:" and add the directory <LEDAAGD> \incl containing the AGD and LEDA include files (Double click on the small rectangle in "Directories", enter <LEDAAGD> \incl, or click on the small grey rectangle on the right and choose the correct directory.)
(15)
Choose "Library Files" in "Show Directories for:" and add the directory <LEDAAGD> containing the AGD and LEDA libraries.
(16)
Click "OK" to leave the "Options"

(17)
In the "Build" menu click on "Build prog.exe" or "Rebuild All" to compile your program.

(18)
In the "Build" menu click on "Execute prog.exe" to execute your program.

Remarks: If your C++ source code files has extension .c, you need to add the option "/Tp" in "Project Options" (Step (9)), otherwise you will get a number of compiler error.

Examples of workspaces can be found in the directory
<LEDAAGD> \demo \msc_workspaces.

Adding AGD to a Project in Microsoft Visual Studio

To link the AGD and LEDA libraries to an already existing project proceed as follows:

(1)
Start the Microsoft Visual Studio with your project
(2)
In the "Project" menu click on "Settings"
(3)
Choose "C/C++" and check in "Project Options" the compiler flag you use for your project. The default value is "/MLd", alternatives are "/ML", "/MD", "/MDd", "/MT", and "/MTd". Notice that you have to use the AGD and LEDA libraries that correspond to the chosen flag, e.g., with option "/MD" you must use libagd_md.lib, libl_md.lib, libg_md.lib, libp_md.lib, and libdw_md.lib. Using another set of libraries with "/MD" will lead to serious linker errors.
(4)
Choose "Linker" and add the name of the AGD and LEDA libraries you want to use at the beginning of line "Object-/Library-Modules" as follows. I use <opt> to indicate the compiler option chosen in Step (3) (,i.e., <opt> is mld for "/MLd", ml for "/ML", ...).
(5)
Click "OK" to leave the "Settings"

(6)
In the "Extras" menu click on "Options"
(7)
Choose "Directories"
(8)
Choose "Include Files" in "Show Directories for:" and add the directory <LEDAAGD> \incl containing the AGD and LEDA include files (Double click on the small rectangle in "Directories", enter <LEDAAGD> \incl, or click on the small grey rectangle on the right and choose the correct directory.)
(9)
Choose "Library Files" in "Show Directories for:" and add the directory <LEDAAGD> containing the AGD and LEDA libraries.
(10)
Click "OK" to leave the "Options"

(11)
You can now use the data types provided by AGD and LEDA in your project as described in this manual.

Compiling and Linking Application Programs in a DOS-Box

(a) Setting the Environment Variables for Visual C++:

The compiler CL.EXE and the linker LINK.EXE require that the environment variables PATH, INCLUDE, and LIB have been set properly. PATH must point to the \bin subdirectory of your Visual C++ installation, LIB must point to \lib, and INCLUDE to \include. When you installed Visual C++, setup created a batch file, VCVARS32.BAT, containing commands to modify the PATH, LIB, and INCLUDE environment variables. Run VCVARS32.BAT before you compile at the command prompt. VCVARS32.BAT is located in the \bin subdirectory.

Note that you do not need to run VCVARS32.BAT if you are compiling your program inside the development environment (see above).

To run VCVARS32.BAT:

To compile programs together with the AGD and LEDA libraries, the environment variables PATH, LIB, and INCLUDE must additionally contain the corresponding AGD/LEDA directories. There are two possibilities to modify the environment variables. The first can be used to change the variables for a single DOS-box, the second to modify the variables permanently.

(b) Setting Environment Variables for AGD and LEDA in a single DOS-Box:

The LEDA/AGD main directory contains the batch file SET_LEDA_PATHS.BAT. This file can be used to change the environment variables as follows:

(c) Setting Environment Variables for AGD and LEDA permanently:
(i) Windows NT/2000:
  1. On the "Start" menu, point to "Settings", then click "Control Panel".
  2. In the "Control Panel", double click "System".
  3. In the System Properties dialog box, click the Environment tab, and specify your environment variable setting for PATH, INCLUDE, and LIB, using the "User Variables for", Variable, and Value boxes.

    If such a user variable already exists, click it in the User Variables for list. The name will then appear in the "Variable" field and its value in the "Value" field. Extend the current value by appending the appropriate LEDA/AGD directory separated by ";" from the existing values as follows:

    • extend PATH by <LEDAAGD>
    • extend INCLUDE by <LEDAAGD> \incl
    • extend LIB by <LEDAAGD>

    In case a user variable does not exist, enter its name in the "Variable" field and the value in the "Value" field.

    • set PATH to <LEDAAGD>
    • set INCLUDE to <LEDAAGD> \incl
    • set LIB to <LEDAAGD>
(ii) Windows 95/98:
  1. Change the file autoexec.bat as follows:

    If the variables PATH, INCLUDE, or LIB are already set in autoexec.bat, append the appropriate LEDA/AGD directory separated by ";" from the existing values as follows:

    • extend PATH by <LEDAAGD>
    • extend INCLUDE by <LEDAAGD> \incl
    • extend LIB by <LEDAAGD>

    If a variable is not set, add it to autoexec.bat by writing:

    set PATH=<LEDAAGD>
    set INCLUDE=<LEDAAGD> \incl
    set LIB=<LEDAAGD>

  2. Restart Windows 95 for the change to take effect.

After these procedures, it suffices to call VCVARS32.BAT at the command prompt. In both cases the LEDA/AGD paths are automatically appended to the compiler paths.

(d) Compiling and Linking Programs:

After setting the environment variables, you can use the libraries as follows to compile and link programs.

Programs without LEDA windows:


cl <options> -Tp prog.c <libagd.lib> <libp.lib> <libg.lib> <libl.lib>

where <options> and <lib*.lib> are related as follows:

<options> <libagd.lib> <libp.lib> <libg.lib> <libl.lib>
         
-ML libagd_ml.lib libp_ml.lib libg_ml.lib libl_ml.lib
-MLd libagd_mld.lib libp_mld.lib libg_mld.lib libl_mld.lib
-MD libagd_md.lib libp_md.lib libg_md.lib libl_md.lib
-MDd libagd_mdd.lib libp_mdd.lib libg_mdd.lib libl_mdd.lib
-MT libagd_mt.lib libp_mt.lib libg_mt.lib libl_mt.lib
-MTd libagd_mtd.lib libp_mtd.lib libg_mtd.lib libl_mtd.lib

Remark: The option -Tp is necessary if the C++ source code files have extension .c, if your files have extension .cpp this option is not necessary.

Programs using LEDA windows:


cl <options> -Tp prog.c <libagd.lib> <libw.lib> <libp.lib>\
 <libg.lib> <libl.lib> wsock32.lib user32.lib gdi32.lib\
 comdlg32.lib  shell32.lib advapi32.lib

where <options> and <lib*.lib> are related analogously to the case above.

Example programs and demos

The source code of all example and demo programs can be found in the directory <LEDAAGD> \test and <LEDAAGD> \demo. Goto <LEDAAGD> and type make_test or make_demo to compile and link all test or demo programs, respectively.

Subsections
next up previous contents index
Next: The AGD Server Up: Technical Information Previous: Unix Object Code Installation   Contents   Index

© Copyright 1998-2001, Algorithmic Solutions Software GmbH. All rights reserved.
2001-08-13