OpenSfM icon indicating copy to clipboard operation
OpenSfM copied to clipboard

Build error: OpenMP_libomp_LIBRARY on MacOs

Open rudyryk opened this issue 3 years ago • 12 comments

Not sure, if this dependency is optional? If so, how to force Cmake to ignore the error?

-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
-- Found AMD library: /opt/local/lib/libamd.dylib
-- Found AMD header in: /opt/local/include
-- Found CAMD library: /opt/local/lib/libcamd.dylib
-- Found CAMD header in: /opt/local/include
-- Found COLAMD library: /opt/local/lib/libcolamd.dylib
-- Found COLAMD header in: /opt/local/include
-- Found CCOLAMD library: /opt/local/lib/libccolamd.dylib
-- Found CCOLAMD header in: /opt/local/include
-- Found CHOLMOD library: /opt/local/lib/libcholmod.dylib
-- Found CHOLMOD header in: /opt/local/include
-- Found CXSPARSE library: /opt/local/lib/libcxsparse.dylib
-- Found SuiteSparseQR library: /opt/local/lib/libspqr.dylib
-- Found SuiteSparseQR header in: /opt/local/include
-- Did not find Intel TBB library, assuming SuiteSparseQR was not compiled with TBB.
-- Found SuiteSparse_config library: /opt/local/lib/libsuitesparseconfig.dylib
-- Found SuiteSparse_config header in: /opt/local/include
-- Found METIS library: /opt/local/lib/libmetis.dylib.
CMake Warning (dev) at /opt/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:424 (message):
  The package name passed to `find_package_handle_standard_args` (ceres) does
  not match the name of the calling package (Ceres).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindCeres.cmake:49 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:38 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Found installed version of gflags: /opt/local/lib/cmake/gflags
-- Detected gflags version: 2.2.2
-- Found OpenCV: /opt/local (found version "3.4.12") 
-- Found OpenCV: /opt/local (found version "3.4.12") found components: core imgproc calib3d imgcodecs 
-- pybind11 v2.2.4
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OpenMP_libomp_LIBRARY (ADVANCED)
    linked by target "foundation" in directory .../Source/OpenSfM/opensfm/src/foundation

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.
Traceback (most recent call last):
  File "setup.py", line 36, in <module>
    configure_c_extension()
  File "setup.py", line 27, in configure_c_extension
    subprocess.check_call(cmake_command, cwd='cmake_build')
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '../opensfm/src', '-DPYTHON_EXECUTABLE=.../.virtualenvs/proto-sfm/bin/python']' returned non-zero exit status 1.

rudyryk avatar Dec 04 '20 09:12 rudyryk

I finally managed to handle OpenMP on my configuration, but it wasn't straightforward.

Long story short:

sudo port install libomp
sudo cp /opt/local/include/libomp/omp.h /opt/local/include
sudo cp /opt/local/lib/libomp/* /opt/local/lib

I have no idea why package installer puts files under non-standard sub directory. After moving headers / libs to the base dir, it worked. I'm using MacPorts, probably with Homebrew it's better configured.

Compiler info:

% llvm-gcc --version                                                                            
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix

As a basic check example for compiler and linker I used the hello world app with omp.h from here: https://stackoverflow.com/questions/23869981/linking-openmp-statically-with-gcc

rudyryk avatar Dec 04 '20 12:12 rudyryk

Thanks for submitting this issue @rudyryk I think it is caused by a recent change, that adds OpenMp headers/libraries explicitly and doesn't rely on it coming from another library such as OpenCV or Ceres. However, it seems that this changes breaks the build when OpenMP is not installed. I'll try to reproduce the problem first and then try to push a fix. Thanks again for reporting and we'll keep you updated.

fabianschenk avatar Dec 04 '20 13:12 fabianschenk

I'd suggest to add some information about OpenMP step to the Installations instructions. If it can be automated, that's awesome! With MacPorts my installation steps were:

sudo port install ceres-solver
sudo port install opencv +python38 +opencl +contrib
# The custom part with OpenMP
sudo port install libomp
sudo cp /opt/local/include/libomp/omp.h /opt/local/include
sudo cp /opt/local/lib/libomp/* /opt/local/lib
# ... common git clone and build via setup.py

rudyryk avatar Dec 04 '20 14:12 rudyryk

Hi, Thanks for posting the installation instructions. I couldn't reproduce the problem on my machine but if another user reports the same problem, we will look into it again.

fabianschenk avatar Dec 14 '20 16:12 fabianschenk

@fabianschenk Interesting... Did you install OpenMP or it wasn't required or it was present before?

I didn't have OpenMP before trying to install OpenSFM, and as I understand, it's not present initially in the OS.

rudyryk avatar Dec 15 '20 13:12 rudyryk

@rudyryk I have OpenMP installed but disabled the OpenMP option in the cmake and also made sure that it wasn't found in another way. OpenSfM then successfully compiled without OpenMP. Before investing too much time, let's see if other people face similar issues. Maybe it was just a misconfiguration or change after an update. It happened to me before that after an update, libraries were not found anymore or were moved into a different directory, etc.

fabianschenk avatar Dec 15 '20 13:12 fabianschenk

I have OpenMP installed but disabled the OpenMP option

Oh, I see. How did you do that, could you provide a hint please? I'm not very familiar with CMake instructions and I guess it's quite common case.

rudyryk avatar Dec 16 '20 08:12 rudyryk

In OpenSfM/opensfm/src/CMakeLists.txt, I commented:

# find_package(OpenMP)

Then I deleted the cmake_build folder and rebuilt. You can also install cmake tool on Mac and check if any of the OpenMP variables for libraries and includes are set.

fabianschenk avatar Dec 16 '20 09:12 fabianschenk

I faced the same problem, and after I installed libomp via homebrew, the CMake error was gone and the build went successfully.

zhengminxu avatar Jan 27 '21 07:01 zhengminxu

I faced the same problem, and after I installed libomp via homebrew, the CMake error was gone and the build went successfully.

Same here. If you use brew, installing by brew install libomp corrects this issue.

richardagalvez avatar May 09 '21 15:05 richardagalvez

after run ○ pip install mkl-devel mkl-static mkl-include ○ conda install intel-openmp ○ brew install libomp I still has the problem: Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)

Call Stack (most recent call first): /opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE) /opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/FindOpenMP.cmake:577 (find_package_handle_standard_args) faiss/CMakeLists.txt:272 (find_package)

image

I'm trying to install faiss in macos m2

shiwanghua avatar Jun 09 '23 14:06 shiwanghua

I'm currently having this same issue. I already had libomp installed, reinstalling didn't change anything. After disabling the OpenMP option as above the build made more progress but still failed when "Linking CXX static library lihbundle.a"

Stack trace (with OpenMP enabled):

$ python setup.py build
Configuring for python 3.8...
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
-- Found AMD library: /usr/local/lib/libamd.dylib
-- Found AMD header in: /usr/local/include/suitesparse
-- Found CAMD library: /usr/local/lib/libcamd.dylib
-- Found CAMD header in: /usr/local/include/suitesparse
-- Found COLAMD library: /usr/local/lib/libcolamd.dylib
-- Found COLAMD header in: /usr/local/include/suitesparse
-- Found CCOLAMD library: /usr/local/lib/libccolamd.dylib
-- Found CCOLAMD header in: /usr/local/include/suitesparse
-- Found CHOLMOD library: /usr/local/lib/libcholmod.dylib
-- Found CHOLMOD header in: /usr/local/include/suitesparse
-- Found CXSPARSE library: /usr/local/lib/libcxsparse.dylib
-- Found SuiteSparseQR library: /usr/local/lib/libspqr.dylib
-- Found SuiteSparseQR header in: /usr/local/include/suitesparse
-- Found Intel Thread Building Blocks (TBB) library: /usr/local/lib/libtbb.dylib, assuming SuiteSparseQR was compiled with TBB.
-- Found Intel Thread Building Blocks (TBB) Malloc library: /usr/local/lib/libtbbmalloc.dylib
-- Found SuiteSparse_config library: /usr/local/lib/libsuitesparseconfig.dylib
-- Found SuiteSparse_config header in: /usr/local/include/suitesparse
-- Found METIS library: /usr/local/lib/libmetis.dylib.
-- Found SuiteSparse: TRUE (found version "..") 
-- Found METIS: /usr/local/include (found suitable version "5.1.0", minimum required is "5.1.0") 
-- Found AMD headers in: /usr/local/include/suitesparse
-- Found AMD library: /usr/local/lib/libamd.dylib
-- Found CAMD headers in: /usr/local/include/suitesparse
-- Found CAMD library: /usr/local/lib/libcamd.dylib
-- Found CCOLAMD headers in: /usr/local/include/suitesparse
-- Found CCOLAMD library: /usr/local/lib/libccolamd.dylib
-- Found CHOLMOD headers in: /usr/local/include/suitesparse
-- Found CHOLMOD library: /usr/local/lib/libcholmod.dylib
-- Found COLAMD headers in: /usr/local/include/suitesparse
-- Found COLAMD library: /usr/local/lib/libcolamd.dylib
-- Found SPQR headers in: /usr/local/include/suitesparse
-- Found SPQR library: /usr/local/lib/libspqr.dylib
-- Found Config headers in: /usr/local/include/suitesparse
-- Found Config library: /usr/local/lib/libsuitesparseconfig.dylib
-- Found Intel Thread Building Blocks (TBB) library (2021.11 / ) include location: . Assuming SuiteSparseQR was compiled with TBB.
-- Could not find librt, but found SuiteSparse_config, assuming that SuiteSparse was compiled without timing.
-- Found METIS: /usr/local/include (found version "5.1.0") 
-- Found SuiteSparse: /usr/local/include/suitesparse (found suitable version "7.7.0", minimum required is "7.3.1") found components: AMD CAMD CCOLAMD CHOLMOD COLAMD SPQR Config 
-- Found required Ceres dependency: Eigen version 3.4.0 in /usr/local/share/eigen3/cmake
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, AccelerateSparse, SchurSpecializations]
-- No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
-- Found installed version of gflags: /usr/local/lib/cmake/gflags
-- Detected gflags version: 2.2.2
-- Found OpenCV: /usr/local/Cellar/opencv/4.9.0_5 (found version "4.9.0") 
-- Found OpenCV: /usr/local/Cellar/opencv/4.9.0_5 (found version "4.9.0") found components: core imgproc calib3d imgcodecs 
CMake Deprecation Warning at third_party/pybind11/CMakeLists.txt:8 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at third_party/pybind11/tools/pybind11Tools.cmake:8 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.
Call Stack (most recent call first):
  third_party/pybind11/CMakeLists.txt:33 (include)


CMake Warning (dev) at third_party/pybind11/tools/FindPythonLibsNew.cmake:60 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  third_party/pybind11/tools/pybind11Tools.cmake:16 (find_package)
  third_party/pybind11/CMakeLists.txt:33 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- pybind11 v2.2.4
-- Configuring done (1.1s)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OpenMP_libomp_LIBRARY (ADVANCED)
    linked by target "foundation" in directory /Users/sil/OpenSfM/opensfm/src/foundation

-- Generating done (0.4s)
CMake Generate step failed.  Build files cannot be regenerated correctly.
Traceback (most recent call last):
  File "setup.py", line 59, in <module>
    configure_c_extension()
  File "setup.py", line 43, in configure_c_extension
    subprocess.check_call(cmake_command, cwd="cmake_build")
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '../opensfm/src', '-DPYTHON_EXECUTABLE=/Users/sil/virtualenvs/opensfm/bin/python']' returned non-zero exit status 1.

Call stack (OpenMP disabled):

. . .

/Users/sil/OpenSfM/opensfm/src/map/shot.h:137:27: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
  const geometry::Camera* const GetCamera() const { return shot_camera_; }
                          ^~~~~~
/Users/sil/OpenSfM/opensfm/src/map/src/tracks_manager.cc:369:21: warning: comparison of integers of different signs: 'int' and 'std::__1::vector<const
      map::TracksManager *, std::__1::allocator<const map::TracksManager *> >::size_type' (aka 'unsigned long') [-Wsign-compare]
  for (int i = 0; i < tracks_managers.size(); ++i) {
                  ~ ^ ~~~~~~~~~~~~~~~~~~~~~~
/Users/sil/OpenSfM/opensfm/src/map/src/tracks_manager.cc:397:23: warning: comparison of integers of different signs: 'int' and 'std::__1::vector<int,
      std::__1::allocator<int> >::size_type' (aka 'unsigned long') [-Wsign-compare]
    for (int i = 1; i < tracks_agg.second.size(); ++i) {
                    ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/sil/OpenSfM/opensfm/src/map/src/tracks_manager.cc:405:21: warning: comparison of integers of different signs: 'int' and
      'std::__1::vector<std::__1::vector<UnionFindElement<std::__1::pair<std::__1::basic_string<char>, int> > *,
      std::__1::allocator<UnionFindElement<std::__1::pair<std::__1::basic_string<char>, int> > *> >,
      std::__1::allocator<std::__1::vector<UnionFindElement<std::__1::pair<std::__1::basic_string<char>, int> > *,
      std::__1::allocator<UnionFindElement<std::__1::pair<std::__1::basic_string<char>, int> > *> > > >::size_type' (aka 'unsigned long')
      [-Wsign-compare]
  for (int i = 0; i < clusters.size(); ++i) {
                  ~ ^ ~~~~~~~~~~~~~~~
3 warnings generated.
3 warnings generated.
3 warnings generated.
5 warnings generated.
3 warnings generated.
[ 77%] Linking CXX static library libmap.a
[ 77%] Built target map
16 warnings generated.
[ 78%] Linking CXX static library libbundle.a
[ 78%] Built target bundle
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 60, in <module>
    build_c_extension()
  File "setup.py", line 54, in build_c_extension
    subprocess.check_call(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-j8']' returned non-zero exit status 2.

si-las avatar Mar 30 '24 23:03 si-las