Troubleshooting installation on macOS

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:

  1. Run the following command in the Terminal on macOS brew install pkg-config and or use sudo apt-get install pkg-config on Linux.
  2. When the installation process is complete, start Julia and type Pkg.dir("Cxx").
  3. Navigate to the path displayed in the last step. Find the src folder and open the Cxx package source code folder.
  4. Right-click on a Cxx.jl and open in an editor such as Sublime, Visual Studio Code.
  5. Navigate to line 141 and find the following code—__precompile__(true).
  1. Put a hashtag (#) sign in front of the line to comment on it.
  2. Get back to Julia and try running using Cxx once again.
  3. 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