OpenCV cannot be precompiled for Julia 1.8

julia> using OpenCV
[ Info: Precompiling OpenCV [f878e3a2-a245-4720-8660-60795d644f2a]
ERROR: LoadError: ccall method definition: argument 2 type doesn't correspond to a C type
Stacktrace:
  [1] top-level scope
    @ none:1
  [2] eval
    @ ./boot.jl:368 [inlined]
  [3] wrap_functions(functions::Vector{CxxWrap.CxxWrapCore.CppFunctionInfo}, julia_mod::Module)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/OcN1Z/src/CxxWrap.jl:695
  [4] wrapfunctions(jlmod::Module)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/OcN1Z/src/CxxWrap.jl:712
  [5] wrapmodule(so_path::String, funcname::Symbol, m::Module, flags::Nothing)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/OcN1Z/src/CxxWrap.jl:731
  [6] top-level scope
    @ ~/.julia/artifacts/365b03f782c1e4bef434b771da708a9d46aeb711/OpenCV/src/cv_cxx.jl:11
  [7] include(mod::Module, _path::String)
    @ Base ./Base.jl:419
  [8] include(x::String)
    @ OpenCV ~/.julia/packages/OpenCV/g5VQi/src/OpenCV.jl:1
  [9] top-level scope
    @ ~/.julia/artifacts/365b03f782c1e4bef434b771da708a9d46aeb711/OpenCV/src/OpenCV.jl:4
 [10] include(mod::Module, _path::String)
    @ Base ./Base.jl:419
 [11] include(x::String)
    @ OpenCV ~/.julia/packages/OpenCV/g5VQi/src/OpenCV.jl:1
 [12] top-level scope
    @ ~/.julia/packages/OpenCV/g5VQi/src/OpenCV.jl:3
 [13] include
    @ ./Base.jl:419 [inlined]
 [14] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}
, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)                          
    @ Base ./loading.jl:1554
 [15] top-level scope
    @ stdin:1
in expression starting at /home/jbpritts/.julia/artifacts/365b03f782c1e4bef434b771da708a9d46aeb711/OpenCV/src/cv_cxx.jl:11
in expression starting at /home/jbpritts/.julia/artifacts/365b03f782c1e4bef434b771da708a9d46aeb711/OpenCV/src/OpenCV.jl:4
in expression starting at /home/jbpritts/.julia/packages/OpenCV/g5VQi/src/OpenCV.jl:1
in expression starting at stdin:1
ERROR: Failed to precompile OpenCV [f878e3a2-a245-4720-8660-60795d644f2a] to /home/jbpritts/.julia/compiled/v1.8/OpenCV/jl_G3gnh8.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
   @ Base ./loading.jl:1707
 [3] compilecache
   @ ./loading.jl:1651 [inlined]
 [4] _require(pkg::Base.PkgId)
   @ Base ./loading.jl:1337
 [5] _require_prelocked(uuidkey::Base.PkgId)
   @ Base ./loading.jl:1200
 [6] macro expansion
   @ ./loading.jl:1180 [inlined]
 [7] macro expansion
   @ ./lock.jl:223 [inlined]
 [8] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:1144

I can confirm, it doesn’t yet work (nor on master, but a PR fix has been approved, see my own fix in my next comment).

If it helps you, then I tested and I got no error in 1.7.3 (no longer supported but should still work). Then it likely would work in 1.6 LTS too.

The problem is:
CxxWrap = “0.11”

CxxWrap 0.12 should work with Julia 1.8.3, and I tried to fix OpenCV to use it [I only allowed 0.12 but didn’t actually update, you don’t need to, <s>it’s already fixed on master</s>, the project only needs to merge a PR and tag a release.], but it doesn’t seem to be enough, so I’m not sure where the problem is.

1 Like

is your kluge for 1.8.3? or should it work for all? so your suggestion is 1.8.3 with cxxwrap 0.12 and the package trick?

I fixed it. You may need to do those exact steps (no need to refer to my Github, I edited that out, the same commit is now upstream):

(@v1.8) pkg> activate .
  Activating project at `~`

pkg> add OpenCV.jl#03929f6

pkg> st
Status `~/Project.toml`
  [1f15a43c] CxxWrap v0.12.1
  [f878e3a2] OpenCV v4.5.2 `https://github.com/archit120/OpenCV.jl.git#03929f6`

It’s actually NOT fixed on master, I was using the dev’ed version with my fix from a long time ago… I just now made the trivial PR to the package, and well someone else also did similar (and that PR was approved 10 days ago):

1 Like