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
The following packages are needed:
- Microsoft Visual C++ 2010 Express
- Microsoft Windows SDK
- WinZip, 7-Zip, or another decompression utility, to extract gzip and tar files
Visual Studio 2010 Service Pack 1 (SP1) deletes the SDK 64-bit compiler . To install the 64-bit compiler proceed as follows:
- install Visual-CPP Microsoft Visual C++ 2010 Express.
- install Microsoft Windows SDK for Windows 7 and .NET Framework 4 without "Visual C++ Compilers".
- install Visual Studio 2010 Service Pack 1 (SP1)
- install Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1
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
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:
For the static library, invoke
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
|the following instructions are probably obsolete and it may be better to simply redirect to Building a C program using the GLPK library!|
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 is Microsoft's embedded operating system.
|the following instructions are not complete — please update them if you can|
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
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
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
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++ 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.