KNITRO.jl. Could not load library .dylib

Hi,
When testing KNITRO, I got the following error:

could not load library “”
dlopen(.dylib, 0x0001): tried: ‘/Users/XXX/knitro-12.3.0-MacOS-64/lib/.dylib’ (no such file), ‘.dylib’ (no such file), ‘/System/Volumes/Preboot/Cryptexes/OS.dylib’ (no such file), ‘/Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia/.dylib’ (no such file), ‘/Applications/Julia-1.8.app/Contents/Resources/julia/lib/.dylib’ (no such file), ‘/usr/lib/.dylib’ (no such file, not in dyld cache), ‘.dylib’ (no such file), ‘/usr/local/lib/.dylib’ (no such file), ‘/usr/lib/.dylib’ (no such file, not in dyld cache)

Any help would be greatly appreciated.

What is ENV["KNITRODIR"]? and KNITRO.has_knitro()?

Do you have a paid copy of KNITRO installed?

KNITRODIR did not exist, so I pointed to the KNITRO folder. Nothing changed. I am getting the same error. I tried pointing to some older releases of KNITRO (I was also changing DYLD_LIBRARY_PATH). It did not work.

**julia>** ENV["KNITRODIR"]

"/Users/XXX/knitro-12.3.0-MacOS-64/"
**julia>** KNITRO.has_knitro()

false

I have a commercial license. KNITRO was downloaded from the artelys website.

1 Like

After setting KNITRODIR, run import Pkg; Pkg.build("KNITRO"), then restart Julia and check KNITRO.has_knitro() again.

**julia>** ENV["KNITRODIR"]="/Users/XXX/knitro-12.3.0-MacOS-64/"

"/Users/XXX/knitro-12.3.0-MacOS-64/"

**julia>** import Pkg;

**julia>** Pkg.build("KNITRO")

**Building** KNITRO → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/f6b5afa744ba4dedc98ac2f4a1496243f5f511b8/build.log`

**Precompiling** project...

1 dependency successfully precompiled in 3 seconds. 46 already precompiled.

**julia>** exit()

and in the new Julia session

**julia>** using KNITRO

**julia>** KNITRO.has_knitro()

false

On Julia 1.6.4. KNITRO cannot find the valid license. But at least it can find all libraries. I guess I updated my Mac OS recently and need a new license since the machine ID has changed. But on Julia 1.8.5, I don’t even get to the stage of checking the license.

Weird. If it works for 1.6, it should work for v1.8.

What’s the output of each line of:

import Libdl
libknitro = joinpath(ENV["KNITRODIR"], "lib", "libknitro.dylib")
Libdl.dlopen(libknitro)
readdir(dirname(libknitro))

So I deleted all versions of Julia and .julia folder and installed Julia 1.8.5 and Julia 1.6.7 from scratch and KNITRO 13.2. I added and build KNITRO in both versions and got the same results.

**julia>** ENV["KNITRODIR"]="/Users/nailkashaev/knitro-13.2.0-MacOS-64/"

"/Users/nailkashaev/knitro-13.2.0-MacOS-64/"

**(@v1.8) pkg>** build KNITRO

**Building** KNITRO → `~/.julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/f6b5afa744ba4dedc98ac2f4a1496243f5f511b8/build.log`

**Precompiling** project...

1 dependency successfully precompiled in 5 seconds. 38 already precompiled.

**julia>** import Libdl

**julia>** libknitro = joinpath(ENV["KNITRODIR"], "lib", "libknitro.dylib")

"/Users/nailkashaev/knitro-13.2.0-MacOS-64/lib/libknitro.dylib"

**julia>** Libdl.dlopen(libknitro)

Ptr{Nothing} @0x00000003085dc190

**julia>** readdir(dirname(libknitro))

9-element Vector{String}:

"libiomp5.dylib"

"libirc.dylib"

"libknitro.a"

"libknitro.dylib"

"libknitro.dylib.13"

"libknitro.dylib.13.2"

"libknitro.dylib.13.2.0"

"libknitro1320.a"

"libknitro1320.dylib"

That all looks fine. What is now:

using KNITRO
KNITRO.has_knitro()
KNITRO.knitro_version()

Thanks. It displays the correct version now. While testing, it cannot find a valid license, which is fine. I will request it tomorrow.
I still don’t know why it works now (maybe installing Julia/knitro from scratch). Either way thank you,

1 Like