mapillary / OpenSfM

Open source Structure-from-Motion pipeline
https://www.opensfm.org/
BSD 2-Clause "Simplified" License
3.34k stars 852 forks source link

building openSFM on Apple M1 MacStudio fails: missing symbols for arm64 #971

Open cwgamma opened 1 year ago

cwgamma commented 1 year ago

I am attempting to build openSFM on a Apple M1 CPU. Others have tried this and submitted an addition to CMakeLists.txt in opensfm/src directory.

For compiling VLFeat

add_definitions(-DVL_DISABLE_AVX)
if( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64" )
    add_definitions( -DVL_DISABLE_SSE2 )
endif()

This correction permitted the build to continue to the linking stage that failed.

Here is the screen output with the error:

Consolidate compiler generated dependencies of target map_test
[ 83%] Building CXX object robust/CMakeFiles/pyrobust.dir/python/pybind.cc.o
[ 84%] Building CXX object sfm/CMakeFiles/sfm.dir/src/retriangulation.cc.o
[ 84%] Building CXX object map/CMakeFiles/pymap.dir/python/pybind.cc.o
[ 85%] Building CXX object sfm/CMakeFiles/sfm.dir/src/ba_helpers.cc.o
[ 86%] Building CXX object sfm/CMakeFiles/sfm.dir/src/tracks_helpers.cc.o
[ 89%] Built target map_test
Undefined symbols for architecture arm64:
  "__ZN6google4base21CheckOpMessageBuilder9NewStringB5cxx11Ev", referenced from:
      __ZN6google17MakeCheckOpStringImiEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc in libgeometry.a(triangulation.cc.o)
      __ZN6google17MakeCheckOpStringIiN5ceres29TinySolverCostFunctionAdapterILin1ELi3EE17ComponentSizeTypeEEEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKT_RKT0_PKc in libgeometry.a(triangulation.cc.o)
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make[2]: *** [geometry/geometry_test] Error 1
make[1]: *** [geometry/CMakeFiles/geometry_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

What is the solution here?

Thanks!

pierotofy commented 1 year ago

Try passing -DOPENSFM_BUILD_TESTS=OFF to cmake.