How to use KNITRO on Ubuntu?

I’m using JuMP and KNITRO on Ubuntu (Remote), the solver KNITRO has been installed successfully, and KNITRO.jl is installed as well, the env command KNITRODIR and LD_LIBRARY_PATH are set, building KNITRO is successful, but using JuMP, KNITRO KNITRO.has_knitro() gives me false, all the packages used are latest, I don’t know why, the following is the error msgs:
ERROR: could not load symbol "KN_new": /opt/julia/bin/julia: undefined symbol: KN_new Stacktrace: [1] KN_new @ ~/data/wjqiao/julia/juliaPkg/packages/KNITRO/tnAEC/src/libknitro.jl:29 [inlined] [2] KN_new() @ KNITRO ~/data/wjqiao/julia/juliaPkg/packages/KNITRO/tnAEC/src/C_wrapper.jl:10 [3] KNITRO.Optimizer(; license_manager::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) @ KNITRO ~/data/wjqiao/julia/juliaPkg/packages/KNITRO/tnAEC/src/MOI_wrapper.jl:146 [4] KNITRO.Optimizer() @ KNITRO ~/data/wjqiao/julia/juliaPkg/packages/KNITRO/tnAEC/src/MOI_wrapper.jl:139 [5] _instantiate_and_check(optimizer_constructor::Any) @ MathOptInterface ~/.julia/packages/MathOptInterface/1fRdT/src/instantiate.jl:94 [6] instantiate(optimizer_constructor::Any; with_bridge_type::Type{Float64}, with_cache_type::Nothing) @ MathOptInterface ~/.julia/packages/MathOptInterface/1fRdT/src/instantiate.jl:175 [7] set_optimizer(model::Model, optimizer_constructor::Any; add_bridges::Bool) @ JuMP ~/.julia/packages/JuMP/PKxEW/src/optimizer_interface.jl:493 [8] Model(optimizer_factory::Any; add_bridges::Bool) @ JuMP ~/.julia/packages/JuMP/PKxEW/src/JuMP.jl:200 [9] Model(optimizer_factory::Any) @ JuMP ~/.julia/packages/JuMP/PKxEW/src/JuMP.jl:192 [10] top-level scope @ ~/data/qwj/tstJuMP.jl:5

Can you share the output of

using Pkg
Pkg.status()

and the output of

versioninfo()

?

I had a similar problem. In the README.md of KNITRO.jl github:

  • If KNITRO.has_knitro() returns false but you are confident that your paths are correct, try running Pkg.build("KNITRO") and restarting Julia. In at least one user’s experience, installing and using KNITRO in a temporary Julia environment (activated with ] activate --temp) does not work and the need to manually build is likely the reason why.

It worked for me.

KNITRODIR should be set such that ${KNITRODIR}/lib/libknitro.so exists.

I’ve clarified this in a PR Clarify installation instructions in the README by odow · Pull Request #304 · jump-dev/KNITRO.jl · GitHub

I have the latest version KNITRO.jl and JuMP.jl, the problem is solved by @odow, thank you.

1 Like

Thank you, it works for me.

1 Like