0

I am attempting to install OpenCV 4 alpha using the following tutorial:https://www.pyimagesearch.com/2018/08...

The primary issue is when compiling with cmake running the command:

cmake -D CMAKE_BUILD_TYPE=RELEASE \ 
-D CMAKE_INSTALL_PREFIX=/usr/local \ 
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \ 
-D PYTHON3_LIBRARY=python -c 'import subprocess ; import sys ; s = subprocess.check_output("python-config --configdir", shell=True).decode("utf-8").strip() ; (M, m) = sys.version_info[:2] ; print("{}/libpython{}.{}.dylib".format(s, M, m))' \ 
-D PYTHON3_INCLUDE_DIR=python -c 'import distutils.sysconfig as s; print(s.get_python_inc())' \ 
-D PYTHON3_EXECUTABLE=$VIRTUAL_ENV/bin/python \ 
-D BUILD_opencv_python2=OFF \ 
-D BUILD_opencv_python3=ON \ 
-D INSTALL_PYTHON_EXAMPLES=ON \ 
-D INSTALL_C_EXAMPLES=OFF \ 
-D BUILD_EXAMPLES=ON ..

Which outputs the following error:

Traceback (most recent call last): File "", line 1, in File "/usr/local/Cellar/python@2/2.7.15_1/F...", line 223, in check_output raise CalledProcessError(retcode, cmd, output=output) subprocess.CalledProcessError: Command 'python-config --configdir' returned non-zero exit status 1 CMake Error at /usr/local/Cellar/cmake/3.12.3/share/cmake/Modules/CMakeDetermineCXXCompiler.cmake:47 (message): Could not find compiler set in environment variable CXX:

/usr/local/bin/g++.

Call Stack (most recent call first): CMakeLists.txt:127 (project)

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred!

Has anyone come up with this issue? I have attempted setting the CXX binary in the bash profile with no luck.

user5316628
  • 357
  • 2
  • 11
  • What would happen if you try to run cmake manually, e.g. `$ mkdir build && cd build` and then `cmake ..`? I just tried and on my mac everything works smoothly. Also you can do those cmake specifications using the GUI, e.g. try `$ cmake-gui` then manually enable those options. – WDC Oct 28 '18 at 10:30
  • Same problem when I use "cmake ..". cmake-gui has command not found. – user5316628 Oct 28 '18 at 10:47
  • If you cannot find `cmake-gui`, then you might need to install it, e.g. (https://stackoverflow.com/questions/10044251/cmake-gui-on-mac). Could you show the problems when using `$ cmake ..`? Also do you have any output from `$ g++ --version`? – WDC Oct 28 '18 at 10:52
  • The error message is clear: `Could not find compiler set in environment variable CXX: /usr/local/bin/g++`. Do you have compiler at the specified path? – Tsyvarev Oct 28 '18 at 11:13
  • @WDC I installed cmake-gui, thanks. But still the exact same error when using cmake .. . The output of g++ version is: Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.11.45.2) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin – user5316628 Oct 28 '18 at 11:13
  • @Tsyvarev that folder doesnt seem to exist on the computer. Is there a way to set this? Through bash profile? – user5316628 Oct 28 '18 at 11:17
  • @user5316628 This is strange because the folder is always there. Try `cd /usr/local/bin` then `ls` to see if you can see any g++ compilers. For mine it is `/usr/local/bin/g++-8`. – WDC Oct 28 '18 at 11:24
  • Problem is fixed by setting the path variables for g++ without local in the filepath, so in bash_profile add the line "export CXX=/usr/bin/g++" without local. Thanks @Tsyvarev and WDC – user5316628 Oct 28 '18 at 11:25
  • The problem you have is likely due to conflicts in your python paths or perhaps virtual environments. If you are using homebrew, sometimes your files will be in `/usr/local/Cellar...` rather than `/usr/local` – Scott Stoltzman Nov 12 '18 at 22:29

0 Answers0