mapillary / mapillary/OpenSfM

Building on macos required cmake changes due to missing header files

Open
#592 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

installation
Dominant language
Python
Stars
3.8k
Forks
899
PR merge metrics
No merged PRs in 30d

Description

When trying to build with python setup.py build I ran into numerous errors due to not found headers. However the dependencies were already present and installed using brew, e.g. brew install gflags opencv ...

  • python 3.7.7
  • cmake version 3.17.2
  • macos 10.15.4.

Example error:

[ 29%] Building C object third_party/vlfeat/CMakeFiles/vl.dir/vl/kmeans.c.o
/OpenSfM/opensfm/src/third_party/gtest/gmock_main.cc:33:10: fatal error: 'gflags/gflags.h' file not found
#include "gflags/gflags.h"
         ^~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/gtest.dir/third_party/gtest/gmock_main.cc.o] Error 1

I had to add include_directories(${GLOG_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIRS}) after the find_packages command to fix the build for my setup.

The complete set of changes which I made.

diff --git opensfm/src/CMakeLists.txt opensfm/src/CMakeLists.txt
index 1d5d881..45eb89e 100644
--- opensfm/src/CMakeLists.txt
+++ opensfm/src/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.0)
+LINK_DIRECTORIES(/usr/local/Cellar)

 project(opensfm C CXX)

@@ -39,6 +39,9 @@ find_package(Eigen REQUIRED)
 find_package(Ceres REQUIRED)
 find_package(Gflags REQUIRED)
 find_package(Glog REQUIRED)
+find_package(gtest REQUIRED)
+
+include_directories(${GLOG_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIRS})

 find_package(OpenCV)
 # OpenCV's OpenCVConfig will enforce imgcodecs for < 3.0

I'm not familiar with cmake and the particulars of its build system but the include_directories command was found via this stackoverflow answer. Using it and other "whack-a-mole" modifications to the CMakeLists.txt allowed a successful build

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with opensfm/src/CMakeLists.txt and reproduce the reported python setup.py build failure on macOS using the listed Python and CMake versions. Review the find_package entries and the reported missing gflags headers; done means the project builds without ad hoc local CMake changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, opencv, python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.