GLPK/Windows

From Wikibooks, open books for an open world
Jump to: navigation, search

This page explains how to compile GLPK from source for a Windows operating system. And, should you wish, how to link to the resulting DLL runtime library. Remember to consult your compiler documentation if you encounter difficulties.

Precompiled option: as an alternative, GLPK is also available as precompiled Windows executables. This is clearly more convenient than compiling from scratch. However a manual build allows you to customize your build configuration so that the resulting library can better match your circumstances and needs.

Microsoft Visual C++ (MSVC) compiler[edit]

The following packages are needed:

Visual Studio 2010 Service Pack 1 (SP1) deletes the SDK 64-bit compiler [1]. To install the 64-bit compiler proceed as follows:

Check if file C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat exists. If not create it with the following content:

CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64

Download the source distribution from ftp://ftp.gnu.org/gnu/glpk/ or from one of the GNU mirrors. Extract the archive using WinZip or similar.

A batch file is used to build GLPK and batch files for different versions of Windows are provided. Users of 64-bit Windows should navigate to the w64 subdirectory, while users of 32-bit Windows should navigate to the w32 subdirectory.

The batch file named Build_GLPK_with_VC10.bat builds GLPK as a static library, whereas the batch file named Build_GLPK_with_VC10_DLL.bat builds GLPK as a dynamic link library. It is normally preferable to build the dynamic link library.

In the batch file Build_GLPK_with_VC10_DLL.bat, the following line specifies where Visual C++ is installed:

set HOME="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"

If necessary, adjust this path by editing the file. The Notepad editor is present on all Windows systems.

You can start the build process by double clicking the batch file from Windows File Explorer. Or you may use a command shell by selecting Run the start menu, typing cmd into the dialog box, and hitting "OK". In which case, first navigate to the path in which you extracted GLPK — in this example, we assume C:\temp, GLPK 4.45, and 64-bit Windows:

> cd C:\temp\glpk-4.45\w64

Then execute the required build script — after making any necessary modifications (see above). For the dynamic link library, invoke:

> Build_GLPK_with_VC10_DLL.bat

For the static library, invoke Build_GLPK_with_VC10.bat instead.

The batch file also runs a test model. Make sure that the following message appears in the console window, toward the end:

OPTIMAL SOLUTION FOUND

Visual Studio project[edit]

A Visual Studio project can also be easily built, but you will need to:

  • provide the location of glpk.h
  • include the two GLPK source subdirectories src/amd and src/colamd

Windows CE[edit]

Windows CE is Microsoft's embedded operating system.

To build a package for Windows CE 6 will require VisualStudio 2005 and Platform Builder. You first build a customized BSP, then an OS Design, and then an SDK for the OS Design. It may better to do all this as a static library and then download the resulting file to your Windows CE device.

You will also need to give the location of glpk.h and include the GLPK src/amd and src/colamd directories within the sub-project for your current OS Design.

Also check this June 2011 thread for more details.

Borland C++ compiler[edit]

Development of the free Borland C++ 5.5 compiler ceased several years ago, but it is still available at edn.embarcadero.com/article/20633.

Build scripts for the Borland C++ compiler were included in GLPK up to version 4.37 and dropped thereafter.

GNU GCC (via MinGW) compiler[edit]

MinGW (Minimalist GNU for Windows) is a port of the GNU Compiler Collection (GCC) and Binutils to enable the development of native Microsoft Windows applications on Windows itself.

Build scripts for MinGW were included in GLPK up to version 4.37 and dropped thereafter.

In the MSYS (Minimal SYStem) environment, GLPK can be built using the appropriate POSIX makefile.

GNU GCC (via Cygwin) compiler[edit]

Cygwin is a Unix-like environment and command-line interface for Microsoft Windows.

In the Cygwin environment, GLPK can be built using the appropriate POSIX makefile.

Dev-C++[edit]

Dev-C++ is Microsoft Windows IDE that fronts the GNU GCC compiler. As of 2011, Dev-C++ is not under active development, although the spin-off project wxDev-C++ is. GLPK used to provide a makefile for Dev-C++ but no longer does. If you need an alternative, consider using Microsoft Visual Studio Express.

References[edit]

  1. "KB2519277 - FIX: Visual C++ compilers are removed when you upgrade Visual Studio 2010 Professional or Visual Studio 2010 Express to Visual Studio 2010 SP1 if Windows SDK v7.1 is installed". Microsoft. 2011-03-30. http://support.microsoft.com/kb/2519277. Retrieved 2012-02-27.