aboutsummaryrefslogtreecommitdiff
path: root/clp-dll/README.md
blob: 672be1314753cef4cc1b0005d142986d24f4d748 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Using Pre-Build Clp Libraries

The COIN Linear Programming libraries are distributed as Windows DLLs that have been compiled using Microsoft's tools.  The resultant distributions can be used with modern GNU Compiler tools in the MinGW64 toolchain, including the compilers shipped with Simply Fortran.  The following documents the necessary steps to deploy and use these prebuilt libraries.

## Acquiring COIN Linear Programming binaries

The binaries for the Clp library and required dependencies can be downloaded from:

<https://bintray.com/coin-or/download/Cbc/master>

The page corresponds to the *master* branch of Clp library development and lists multiple builds corresponding to different platforms and compiler versions.  For simplicity and interoperability, the proper archive to download for Windows 10 64-bit from the master branch is:

**[Cbc-master-win64-msvc16-md.zip](https://bintray.com/coin-or/download/download_file?file_path=Cbc-master-win64-msvc16-md.zip)**
    
The version of the compiler (*msvc16*) does help indicate on what versions of Windows the libraries will work.  If Windows 7 compatibility is necessary, an older archive (*msvc14*) might be superior.

To select a specific release version, go to the [Bintray project page](https://bintray.com/coin-or/download/Cbc) and select "View All" under the "Versions" heading.  Selecting a version from the list should allow you to download a particular released version for Windows.

## Extract the Necessary Files

To use the DLLs, we will need to pull three things from the downloaded archive:

 * The DLLs themselves
 * Additional DLLs that provide dependencies
 * The static libraries for linking purposes

Within the archive, there will be four directories and some additional text files.  To use Clp, the following files should be copied *into this directory* such that they can be used with the example Simply Fortran project:

    bin\Clp-0.dll
    bin\CoinUtils-0.dll
    bin\coinasl-2.dll
    bin\coinglpk-40.dll
    lib\Clp.dll.lib
    lib\CoinUtils.dll.lib
    
The files *Clp-0.dll* and *CoinUtils-0.dll* are the base libraries implementing Clp.  These DLLs, in turn, depend on *coinasl-2.dll* and *coinglpk-40.dll* at runtime.  All four DLLs must be in the same directory as any executale that is using them.

The files *Clp.dll.lib* and *CoinUtils.dll.lib* are static libraries providing the necessary linking interface to these DLLs.  The libraries are Microsoft-format, but modern GNU tools, including those shipped with Simply Fortran, can link against this format without any changes.

The above are the only files necessary for compiling and linking against the COIN Linear Programming library from Fortran.  If using C/C++ is planned, the corresponding header files would also be necessary.

## Compiling the Clp-Fortran Interface

When compiling the Fortran interface to a DLL, the linker must be provided with the static import libraries (ending in *.lib*) during the process.  For simplicity, in the topmost directory, a Simply Fortran project, *libClpFortran.dll.prj* is included that is pre-configured to link with the two necessary import libraries that should reside in this directory.  The resultant library DLL will be created in this directory as well.

The project will also produce a static import library for the Fortran interface, nominally named *libClpFortran.dll.a*, in this directory that can be used for linking projects utilizing the Clp-Fortran interface as well.

## Compiling Code that Uses the Clp-Fortran Interface

To use the Clp-Fortran interface, code must link to the requisite DLL import libraries:

 * libClpFortran.dll.a
 * Clp.dll.lib
 * CoinUtils.dll.lib

Additionally, the Fortran modules associated with the Clp-Fortran interface must be on the module search path for the compiler.  The project mentioned above that is configured to build the Clp-Fortran interface DLL produces modules in the *modules* subdirectory of this directory.

When running the executable, the following DLLs must be present in the same directory as the executable file:

 * libClpFortran.dll
 * Clp-0.dll
 * CoinUtils-0.dll
 * coinasl-2.dll
 * coinglpk-40.dll

An example Simply Fortran project, *clp-example-using-dlls.prj*, is included in the parent directory that builds a converted version of the Clp example driver for the C interface.  This example can be used as a starting point for additional projects as it has all compiler flags properly configured.

---

*by Jeff Armstrong (jeff@approximatrix.com)*

*Initial Release: 2020-10-30* 

*Updated: 2021-01-13*