Skip to content

Commit

Permalink
Merge pull request #129 from JuliaOpt/fix128
Browse files Browse the repository at this point in the history
Add CPLEX_STUDIO_BINARIES ENV on unix #128
  • Loading branch information
joehuchette committed Apr 30, 2017
2 parents 73465ad + 1b5ca87 commit cdd190f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ NOTE: CPLEX [does not officially support linking to their dynamic C library](htt

1. First, you must obtain a copy of the CPLEX software and a license; trial versions and academic licenses are available [here](http://www-01.ibm.com/software/websphere/products/optimization/cplex-studio-preview-edition/).

2. Once CPLEX is installed on your machine, point the LD_LIBRARY_PATH variable to the directory containing the CPLEX library by adding, for example, ``export LD_LIBRARY_PATH="/path/to/cplex/bin/x86-64_linux":$LD_LIBRARY_PATH`` to your start-up file (e.g. ``.bash_profile``, [adding library path on Ubuntu](http://stackoverflow.com/questions/13428910/how-to-set-the-environmental-variable-ld-library-path-in-linux for a)). On linux, make sure this directory contains ``libcplexXXX.so`` where ``XXX`` is stands for the version number; on OS-X the file should be named ``libcplexXXX.dylib``.
2. Once CPLEX is installed on your machine, point the `LD_LIBRARY_PATH` variable to the directory containing the CPLEX library by adding, for example, ``export LD_LIBRARY_PATH="/path/to/cplex/bin/x86-64_linux":$LD_LIBRARY_PATH`` to your start-up file (e.g. ``.bash_profile``, [adding library path on Ubuntu](http://stackoverflow.com/questions/13428910/how-to-set-the-environmental-variable-ld-library-path-in-linux for a)). On linux, make sure this directory contains ``libcplexXXX.so`` where ``XXX`` is stands for the version number; on OS-X the file should be named ``libcplexXXX.dylib``. Alternatively, you can also use the `CPLEX_STUDIO_BINARIES` environment variable as follows:
```
$ CPLEX_STUDIO_BINARIES=/path/to/cplex/bin/x86-64_linux julia -e 'Pkg.add("CPLEX"); Pkg.build("CPLEX")'
```

3. At the Julia prompt, run
```
Expand Down
7 changes: 6 additions & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if is_apple()
Libdl.dlopen("libstdc++",Libdl.RTLD_GLOBAL)
end

base_env = "CPLEX_STUDIO_BINARIES"

cpxvers = ["1260","1261","1262","1263","1270", "1271"]

libnames = String["cplex"]
Expand All @@ -23,13 +25,16 @@ for v in reverse(cpxvers)
push!(libnames, "libcplex$v.dylib")
elseif is_unix()
push!(libnames, "libcplex$v.so")
if haskey(ENV, base_env)
push!(libnames, joinpath(ENV[base_env], "libcplex$v.so"))
end
end
end

wincpxvers = ["126","1261","1262","1263","127","1270","1271"]
if is_windows()
for v in reverse(wincpxvers)
env = "CPLEX_STUDIO_BINARIES$v"
env = base_env * v
if haskey(ENV,env)
for d in split(ENV[env],';')
contains(d,"cplex") || continue
Expand Down

0 comments on commit cdd190f

Please sign in to comment.