So, I guess I managed to go pretty far. Both BaPCod and CPLEX are installed, and I just tried to run VrpSolver julia interface. But I get:
❮onyr ★ nixos❯ ❮BaPCodVRPSolver.jl❯❯ julia vrpsolver/src/run.jl vrpsolver/data/100/C204.txt --cfg vrpsolver/config/VRPTW_set_2.cfg
Application parameters:
batch => nothing
tikz => nothing
instance => "vrpsolver/data/100/C204.txt"
out => nothing
nosolve => false
ub => 1.0e7
sol => nothing
cfg => "vrpsolver/config/VRPTW_set_2.cfg"
enable_cap_res => false
solve
ERROR: LoadError: could not load library "/home/onyr/bapcod/bapcod-0.82.8/build/Bapcod/libbapcod-shared.so"
/nix/store/26v9009yj6yyz60261523pzvbj2vv4jc-gfortran-9.3.0-lib/lib/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/onyr/bapcod/bapcod-0.82.8/build/Bapcod/libbapcod-shared.so)
Stacktrace:
[1] macro expansion at /home/onyr/code/phd/BaPCodVRPSolver.jl/src/bapcod/bc_common.jl:12 [inlined]
[2] new!(::String, ::Bool, ::Bool, ::Bool, ::Int32, ::Array{String,1}) at /home/onyr/code/phd/BaPCodVRPSolver.jl/src/bapcod/wrapper/model.jl:19
[3] BaPCodVRPSolver.BaPCod.BcModel(; param_file::String, print_param::Bool, integer_objective::Bool, baptreedot_file::String, user_params::String) at /home/onyr/code/phd/BaPCodVRPSolver.jl/src/bapcod/bc_model.jl:20
[4] BaPCodVRPSolver.BaPCod.BcMathProgModel(::BaPCodVRPSolver.BaPCod.BaPCodSolver) at /home/onyr/code/phd/BaPCodVRPSolver.jl/src/bapcod/BaPCodSolverInterface.jl:132
[5] LinearQuadraticModel at /home/onyr/code/phd/BaPCodVRPSolver.jl/src/bapcod/BaPCodSolverInterface.jl:134 [inlined]
[6] build(::Model; suppress_warnings::Bool, relaxation::Bool, traits::JuMP.ProblemTraits) at /home/onyr/.julia/packages/JuMP/I7whV/src/solvers.jl:358
[7] solve(::Model; suppress_warnings::Bool, ignore_solve_hook::Bool, relaxation::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/onyr/.julia/packages/JuMP/I7whV/src/solvers.jl:168
[8] vrp_hook(::Model; suppress_warnings::Bool, relaxation::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/onyr/code/phd/BaPCodVRPSolver.jl/src/BaPCodVRPSolver.jl:2425
[9] solve(::Model; suppress_warnings::Bool, ignore_solve_hook::Bool, relaxation::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/onyr/.julia/packages/JuMP/I7whV/src/solvers.jl:151
[10] solve at /home/onyr/.julia/packages/JuMP/I7whV/src/solvers.jl:150 [inlined]
[11] optimize!(::VrpOptimizer) at /home/onyr/code/phd/BaPCodVRPSolver.jl/src/BaPCodVRPSolver.jl:1767
[12] run_vrptw(::Dict{String,Any}) at /home/onyr/code/phd/BaPCodVRPSolver.jl/vrpsolver/src/run.jl:61
[13] main(::Array{String,1}) at /home/onyr/code/phd/BaPCodVRPSolver.jl/vrpsolver/src/run.jl:101
[14] top-level scope at /home/onyr/code/phd/BaPCodVRPSolver.jl/vrpsolver/src/run.jl:108
[15] include(::Function, ::Module, ::String) at /nix/store/s5ydxxzjjahgq3jj6jissi2m5qgwh1hw-julia-1.5.4/lib/julia/sys.so:? (repeats 2 times)
[16] exec_options(::Base.JLOptions) at /nix/store/s5ydxxzjjahgq3jj6jissi2m5qgwh1hw-julia-1.5.4/lib/julia/sys.so:?
[17] _start() at /nix/store/s5ydxxzjjahgq3jj6jissi2m5qgwh1hw-julia-1.5.4/lib/julia/sys.so:?
in expression starting at /home/onyr/code/phd/BaPCodVRPSolver.jl/vrpsolver/src/run.jl:105
Indeed, I was expecting something like that to happen since the README says:
Troubleshooting
On Linux, you may have error:
ERROR: LoadError: could not load library "<path to>/libbapcod-shared.so"
<path to Julia>/bin/../lib/julia/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by "<path to>/libbapcod-shared.so")
This is because Julia comes with an older version of the libstdc++.so.6
library. One solution is build Julia from sources.
An easier solution is to replace file <path to Julia>/lib/julia/libstdc++.so.6
with your system libstdc++.so.6
file. For local machines it is usually located in the folder /usr/lib/x86_64-linux-gnu/
.
Which rises from this code snippet:
if !haskey(ENV, "BAPCOD_RCSP_LIB")
error("The env. variable BAPCOD_RCSP_LIB was not set with the BaPCod+RCSP library path!")
end
libdevjulia = ENV["BAPCOD_RCSP_LIB"]
## ccall redef
macro bcm_ccall(func, args...)
f = "bcInterfaceModel_$(func)"
args = map(esc, args)
return quote
ccall(($f, $libdevjulia), $(args...))
end
end
This calls the BaPCod libbapcod-shared.so
file.
So I have two options:
- Find a way to change the path that Julia is looking for, directly in my
flake
, although since julia packages are immutable, I doubt this is even possible…
- Modify
julia
derivation so it builds a version that has a working libstdc++.so.6
… The README doesn’t really specify which version to use but since so far everything works using Nixpkgs channel "github:NixOS/nixpkgs/nixos-22.11"
I guess using a depencency for gfortran
from this channel would work.
Looking at the build file for Julia 1.5.4 directly from an old commit of Nixpkgs (see on GitHub) I see:
{ lib, stdenv, fetchzip
# build tools
, gfortran, m4, makeWrapper, patchelf, perl, which, python2, cmake
# libjulia dependencies
, libunwind, readline, utf8proc, zlib
# standard library dependencies
, curl, fftwSinglePrec, fftw, libgit2, mpfr, openlibm, openspecfun, pcre2
# linear algebra
, blas, lapack, arpack
# Darwin frameworks
, CoreServices, ApplicationServices
}:
So indeed, Julia 1.5.4 depends on gfortran
. How could I override it so that it uses gfortran
from channel nixos-22.11
instead of this older derivation ?
Here is my flake so far:
{
description = "Julia 1.5 environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
nixpkgs-julia-15.url = "github:NixOS/nixpkgs/75a93dfecc6c77ed7c35cc7f906175aca93facb4"; # Pin to the specific commit
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixpkgs-julia-15, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlay-nixpkgs-julia-15 = final: prev: {
# Use the non-flake store path
pkgs-julia-15 = import nixpkgs-julia-15 { inherit system; };
};
pkgs = import nixpkgs {
system = system;
config.allowUnfree = true; # Allow unfree packages if needed
overlays = [ overlay-nixpkgs-julia-15 ];
};
julia_15 = pkgs.pkgs-julia-15.julia_15.overrideDerivation (oldAttrs: { doInstallCheck = false; });
in {
devShells.default = pkgs.mkShell {
packages = [
julia_15 # Use specific Julia 1.5.4
pkgs.cmake
pkgs.gcc
pkgs.gdb
pkgs.zlib
pkgs.unzip
];
shellHook = ''
export JULIA_NUM_THREADS="auto"
export JULIA_PROJECT="."
export JULIA_BINDIR=${julia_15}/bin
export JULIA_EDITOR="code"
alias julia=${julia_15}/bin/julia
export LD_LIBRARY_PATH=/home/onyr/cplex1210/cplex/bin/x86-64_linux:$LD_LIBRARY_PATH
export CPLEX_ROOT=/home/onyr/cplex1210
export BAPCOD_ROOT=/home/onyr/bapcod/bapcod-0.82.8
export BOOST_ROOT=/home/onyr/bapcod/bapcod-0.82.8/Tools/boost_1_76_0/build
export BAPCOD_RCSP_LIB=/home/onyr/bapcod/bapcod-0.82.8/build/Bapcod/libbapcod-shared.so
echo "Julia 1.5 Nix shell loaded."
'';
};
});
}