next up previous contents index
Next: Namespaces and Interaction with Up: Technical Information Previous: Static Libraries for MS   Contents   Index

Subsections

DLL's for MS Visual C++ .NET

This section describes the installation and usage of LEDA Dynamic Link Libraries (DLL's) with Microsoft Visual C++ .NET.

Preparations

To install LEDA you only need to execute the LEDA distribution file LEDA-<ver>-<package>-win32-<compiler>.exe. During setup you can choose the name of the LEDA root directory and the parts of LEDA you want to install.

Then you have to set the environment variable LEDAROOT. On MS Windows 10 this can be done as follows:

MS Windows 10:
  1. Open the Start Search, type in “env”, and choose “Edit the system environment variables”. A window titled "System Properties" should open.

  2. Click the button "Environment variables..." in the lower right corner of the "System Properties" window. A new window opens that allows to add/change/delete the user variables for your account as well as the system variables, provided you have admin rights. If not, change the environment variables of your account.

    Add a new user variable LEDAROOT with value <LEDA>.

In case you are working on a different version of MS Windows, please consult the documentation of your version in order to learn how to perform the corresponding steps. You might have to restart your computer for the changes to take effect.

Files and Directories

To compile and link your programs with LEDA, the LEDA main directory should contain the following files and subdirectories:
Readme.txt Readme File
incl \ the LEDA include directory
and at least one of the following dll/library sets

Note: A DLL of GeoWin is currently not available.

Compiling and Linking in Microsoft Visual C++ .NET


We now explain how to proceed in order to compile and link an application program using LEDA with MS Visual Studio 2017. If you are using a different version of MS Visual Studio, please read and understand the guidelines below and consult the documentation of your version of the Studio in order to learn how to perform the corresponding steps.

(1)
In the "File" menu of Visual C++ .NET click on "New->Project".
(2)
Choose "Visual C++" as project type and choose "Empty Project".
(3)
Enter a project name, choose a directory for the project, and click "OK".
(4)
After clicking "OK" you have an empty project space. Choose, for instance, "Debug" and "x64" (or "x86" in case you are working on a 32-bit system) in the corresponding pick lists.
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 Solution Explorer of your project click on "Source Files" with the right mouse button, then click on "Add-> Add Existing Item" with the left mouse button
(7)
Double click on prog.cpp
If you want to enter a new source file:
(5')
In the Solution Explorer of your project click on "Source Files" with the right mouse button, then click on "Add-> Add New Item" with the left mouse button.
(6')
Choose "C++ File" in Templates, enter a name, and click "Add".
(7')
Enter your code.
(8)
In the Solution Explorer right click on your project and left click on "Properties"
(9a)
Click on "C/C++" and "Code Generation" and choose the "Run Time Library" (=compiler flag) you want to use.

If you chose "Debug" in step 4, the default value is now "/MDd", alternatives are "/MD", "/MT", and "/MTd". Notice that you have to use the LEDA libraries that correspond to the chosen flag, e.g., with option "/MDd" you must use libleda_mdd.lib and libgeow_mdd.lib. Using another set of libraries with "/MDd" could lead to serious linker errors.

(9b)
Click on "C/C++" and "Preprocessor" and add /D "LEDA_DLL" in "Preprocessor Definitions".
(10)
Click on "Linker" and "Command Line" and add the name of the LEDA libraries you want to use in "Additional Options" as follows. We use <opt> to indicate the compiler option chosen in Step (9) (e.g., <opt> is mdd for "/MDd"). Alternatively, you can include <LEDA/msc/autolink_dll.h> in your program and the correct LEDA libraries are linked to your program automatically. If GeoWin is used you need to add "_LINK_GeoW" to the "Preprocessor definitions" in Step (9).
(11)
Click on "VC++ Directories" of the "Properties" window.
(12)
Choose "Include Files" and add the directory <LEDA> \incl containing the LEDA include files (Click on the line starting with "Include Files", then click on "Edit..." in the pick list at the right end of that line. Push the "New line" button and then enter <LEDA> \incl, or click on the small grey rectangle on the right and choose the correct directory.) Alternatively you can click C/C++-> General in the Configuration Properties and then edit the line "Additional Include Directories".
(13)
Choose "Library Directories" and add the directory <LEDA> containing the LEDA libraries.
(14)
Click "OK" to leave the "Properties"
(15)
In the "Build" menu click on "<Build Project>" or "Rebuild <Project>" to compile your program.
(16)
To execute the program "prog.exe" Windows needs to have leda_<opt>.dll in its search path for DLL's. Therefore, you need to do one of the following.
(17)
In order to execute your program, click the green play button in the tool bar.

Remark: If your C++ source code files has extension .c, you need to add the option "/TP" in "Project Options" (similar to Step (9)), otherwise you will get a number of compiler errors. (Click on "C/C++" and "Command Line". Add /TP in "Additional Options" and click "Apply".)

If you chose "Debug" for your project type, the default value is "/MDd", alternatives are "/MD", "/MT", and "/MTd". Notice that you have to use the LEDA libraries that correspond to the chosen flag, e.g., with option "/MDd" you must use leda_mdd.lib and libGeoW_mdd.lib. Using another set of libraries with "/MDd" could lead to serious linker errors.

To add LEDA to an existing Project in Microsoft Visual C++ .NET, start the Microsoft Visual Studio with your project and follow Steps (8)-(14) above.

Compiling and Linking Application Programs in a DOS-Box

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

The compiler CL.EXE and the linker LINK.EXE require that the environment variables PATH, INCLUDE, and LIB have been set properly. This can easily be ensured by using the command prompts that are installed on your computer with your Visual Studio installation.

To compile programs together with LEDA, the environment variables PATH, LIB, and INCLUDE must additionally contain the corresponding LEDA directories. We now explain how to do that with MS Windows 10. If you are using a different version of MS Windows, please read and understand the guidelines below and consult the documentation of your operating system in order to learn how to perform the corresponding steps.

(b) Setting Environment Variables for LEDA:
MS Windows 10:
  1. Open the Start Search, type in “env”, and choose “Edit the system environment variables”. A window titled "System Properties" should open.

  2. Click the button "Environment variables..." in the lower right corner of the "System Properties" window. A new window opens that allows to add/change/delete the user variables for your account as well as the system variables, provided you have admin rights. If not, change the environment variables of your account.

    If a user variable PATH, LIB, or INCLUDE already exists, extend the current value as follows:

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

    Otherwise add a new user variable PATH, INCLUDE, or LIB with value <LEDA>, respectively <LEDA> \incl.

You might have to restart your computer for the changes to take effect.

(c) Compiling and Linking Application Programs:

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

Programs that do not use GeoWin:

      cl <option> -DLEDA_DLL prog.cpp <libleda.lib>
Programs using GeoWin:
      cl <option> -DLEDA_DLL prog.cpp <libGeoW.lib> <libleda.lib>
Possible values for <option> are "-MD", "-MDd", "-MT", and "-MTd". You have to use the LEDA libraries that correspond to the chosen <option>, e.g., with option "-MD" you must use leda_md.lib and libGeoW_md.lib. Using another set of libraries with "-MD" could lead to serious linker errors.

Example programs and demos

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


next up previous contents index
Next: Namespaces and Interaction with Up: Technical Information Previous: Static Libraries for MS   Contents   Index