Users might experience problems installing the Cxx package and running the OpenCV package on macOS. Consider the following code:
julia> using OpenCV
INFO: Precompiling module Cxx.
ERROR: LoadError: Failed to precompile Cxx to /Users/<<username>>/.julia/lib/v0.6/Cxx.ji.
There is an issue in GitHub and a number of solutions provided. If you are experiencing a problem running using Cxx, complete the following set of steps:
- Run the following command in the Terminal on macOS brew install pkg-config and or use sudo apt-get install pkg-config on Linux.
- When the installation process is complete, start Julia and type Pkg.dir("Cxx").
- Navigate to the path displayed in the last step. Find the src folder and open the Cxx package source code folder.
- Right-click on a Cxx.jl and open in an editor such as Sublime, Visual Studio Code.
- Navigate to line 141 and find the following code—__precompile__(true).
- Put a hashtag (#) sign in front of the line to comment on it.
- Get back to Julia and try running using Cxx once again.
- Verify that the package loaded successfully.
With the preceding steps listed, we turn off code precompilation.
Reference: https://github.com/Keno/Cxx.jl/issues/369