colmap / pycolmap

Python bindings for COLMAP
BSD 3-Clause "New" or "Revised" License
858 stars 125 forks source link

Error when building from source #239

Closed TruongKhang closed 5 months ago

TruongKhang commented 5 months ago

Hi Mr. Sarlin,

Thank you for the great code. I'm a big fan of your works.

I've already installed COLMAP 3.9.1. I'm trying to build the latest version of pycolmap from source. When I run python -m pip install ., the error looks like this:

Processing /home/khangtg/pycolmap
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy in /home/khangtg/anaconda3/envs/torch12cu113/lib/python3.8/site-packages (from pycolmap==0.5.0) (1.23.5)
Building wheels for collected packages: pycolmap
  Building wheel for pycolmap (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pycolmap (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [117 lines of output]
      *** scikit-build-core 0.7.1 using CMake 3.28.1 (wheel)
      *** Configuring CMake...
      2024-01-17 14:40:50,417 - scikit_build_core - WARNING - libdir/ldlibrary: /home/khangtg/anaconda3/envs/torch12cu113/lib/libpython3.8.a is not a real file!
      2024-01-17 14:40:50,418 - scikit_build_core - WARNING - Can't find a Python library, got libdir=/home/khangtg/anaconda3/envs/torch12cu113/lib, ldlibrary=libpython3.8.a, multiarch=x86_64-linux-gnu, masd=None
      loading initial cache file /tmp/tmp4nkc__km/build/CMakeInit.txt
      -- The C compiler identification is GNU 7.5.0
      -- The CXX compiler identification is GNU 6.5.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /usr/bin/cc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Found Boost: /usr/include (found version "1.65.1") found components: filesystem graph program_options system
      -- Found Eigen3: /usr/include/eigen3 (Required is at least version "2.91.0")
      -- Found Eigen
      --   Includes : /usr/include/eigen3
      -- Found FreeImage
      --   Includes : /usr/include
      --   Libraries : /usr/lib/x86_64-linux-gnu/libfreeimage.so
      -- Found FLANN
      --   Includes : /usr/local/include
      --   Libraries : /usr/local/lib/libflann.so
      -- Found LZ4
      --   Includes : /usr/include
      --   Libraries : /usr/lib/x86_64-linux-gnu/liblz4.so
      -- Found Metis
      --   Includes : /usr/include
      --   Libraries : /usr/lib/x86_64-linux-gnu/libmetis.so
      -- Found Glog
      --   Includes : /usr/include
      --   Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
      -- Found SQLite3
      --   Includes : /usr/include
      --   Libraries : /usr/lib/x86_64-linux-gnu/libsqlite3.so
      -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
      -- Found Glew
      --   Includes : /usr/include
      --   Libraries : /usr/lib/x86_64-linux-gnu/libGLEW.so
      -- Found Git: /usr/bin/git (found version "2.17.1")
      -- Found installed version of Eigen: /usr/lib/cmake/eigen3
      -- Found required Ceres dependency: Eigen version 3.3.4 in /usr/include/eigen3
      -- Found required Ceres dependency: glog
      -- Found installed version of gflags: /usr/lib/x86_64-linux-gnu/cmake/gflags
      -- Detected gflags version: 2.2.1
      -- Found required Ceres dependency: gflags
      -- Found Ceres version: 1.14.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, CXSparse, SchurSpecializations, OpenMP, Multithreading]
      -- Enabling OpenMP support
      -- Found CGAL
      --   Includes : /usr//include
      --   Libraries : /usr/lib/x86_64-linux-gnu/libCGAL.so.13.0.1
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
      -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
      -- Looking for pthread_create in pthreads
      -- Looking for pthread_create in pthreads - not found
      -- Looking for pthread_create in pthread
      -- Looking for pthread_create in pthread - found
      -- Found Threads: TRUE
      -- The CUDA compiler identification is NVIDIA 11.3.58
      -- Detecting CUDA compiler ABI info
      -- Detecting CUDA compiler ABI info - done
      -- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped
      -- Detecting CUDA compile features
      -- Detecting CUDA compile features - done
      -- Enabling CUDA support (version: 11.3.58, archs: 86)
      -- Found Qt
      --   Module : /usr/lib/x86_64-linux-gnu/cmake/Qt5Core
      --   Module : /usr/lib/x86_64-linux-gnu/cmake/Qt5OpenGL
      --   Module : /usr/lib/x86_64-linux-gnu/cmake/Qt5Widgets
      -- Enabling GUI support
      -- Disabling OpenGL support
      -- Enabling GPU support
      -- Found Python: /home/khangtg/anaconda3/envs/torch12cu113/bin/python (found version "3.8.16") found components: Interpreter Development.Module
      -- Performing Test HAS_FLTO
      -- Performing Test HAS_FLTO - Success
      -- Found pybind11: /home/khangtg/anaconda3/envs/torch12cu113/lib/python3.8/site-packages/pybind11/include (found version "2.10.3")
      -- Configuring done (1.5s)
      CMake Error at /usr/local/share/colmap/colmap-targets.cmake:138 (set_target_properties):
        The link interface of target "colmap::colmap_scene" contains:

          SQLite::SQLite3

        but the target was not found.  Possible reasons include:

          * There is a typo in the target name.
          * A find_package call is missing for an IMPORTED target.
          * An ALIAS target is missing.

      Call Stack (most recent call first):
        /usr/local/share/colmap/colmap-config.cmake:105 (include)
        CMakeLists.txt:18 (find_package)

      CMake Error at /usr/local/share/colmap/colmap-targets.cmake:159 (set_target_properties):
        The link interface of target "colmap::colmap_util" contains:

          SQLite::SQLite3

        but the target was not found.  Possible reasons include:

          * There is a typo in the target name.
          * A find_package call is missing for an IMPORTED target.
          * An ALIAS target is missing.

      Call Stack (most recent call first):
        /usr/local/share/colmap/colmap-config.cmake:105 (include)
        CMakeLists.txt:18 (find_package)

      -- Generating done (0.0s)
      CMake Generate step failed.  Build files cannot be regenerated correctly.

      *** CMake configuration failed
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycolmap
Failed to build pycolmap
ERROR: Could not build wheels for pycolmap, which is required to install pyproject.toml-based projects

I wonder how to fix this issue. Thank you!

sarlinpe commented 5 months ago

Solved in https://github.com/colmap/pycolmap/issues/226:

-- Found SQLite3
  --   Includes : /usr/include
  --   Libraries : /usr/lib/x86_64-linux-gnu/libsqlite3.so

is the log printed by the old, broken FindSQLite3.cmake shipped in COLMAP <= 3.8; CMake>=3.14 ships it own FindSQLite3.cmake, which properly defines the SQLite::SQLite3 target: https://cmake.org/cmake/help/latest/module/FindSQLite3.html Maybe you didn't properly uninstall 3.8 and the file /usr/local/share/colmap/cmake/FindSQLite3.cmake remains?

TruongKhang commented 5 months ago

I'm able to build pycolmap 0.4.0 with colmap 3.8. Just close this issue for now. I'll try to upgrade to pycolmap 0.5.0 and colmap 3.9 in the future, and come back if this issue happens again!