nmoehrle / mvs-texturing

Algorithm to texture 3D reconstructions from multi-view stereo images
Other
974 stars 334 forks source link

OSX compile fix #148

Open pavan4 opened 4 years ago

pavan4 commented 4 years ago
ndahlquist commented 4 years ago

Confirmed this fixes the issue on OS X for me. Thank you so much @pavan4 !

CodeAunt commented 2 years ago
  • Fixes the compilation issue on OSX Catalina
  • Need to install openmp and tbb using: brew install tbb libomp
  • Assumes tbb and omp libraries are in /usr/local/include else specify path in CMakeLists.txt

my tbb is installed in /opt/homebrew/Cellar/tbb@2020/ as tbb@2020 and I failed to compile the project where I use tbb. It seems that CMake fail to recognize it. And /opt/homebrew/include/openapi is an empty directory.

the new tbb@2021 differs to 2020 version a lot.

using Monterey and apple m1 chip

pavan4 commented 2 years ago

@CodeAunt yes you are right. This PR is not updated for the latest OSX updates. The latest tbb changes (openapi) require a lot of changes. I will take a stab at it and try tp put a PR but I have resorted to running this on a docker container with Ubuntu base on OSX and pinned all the repositories to old versions (for tbb etc.,.)

CodeAunt commented 2 years ago

@CodeAunt yes you are right. This PR is not updated for the latest OSX updates. The latest tbb changes (openapi) require a lot of changes. I will take a stab at it and try tp put a PR but I have resorted to running this on a docker container with Ubuntu base on OSX and pinned all the repositories to old versions (for tbb etc.,.)

Thanks for your advice and work. I also started trying to deploy it on Ubuntu.

CodeAunt commented 2 years ago

@pavan4 Hi, I'm using ubuntu now, but still encountered this problem. And the error after executing make -j:

[ 98%] Building CXX object apps/texrecon/CMakeFiles/texrecon.dir/texrecon.cpp.o
/home/jessie/Desktop/mvs-texturing/apps/texrecon/texrecon.cpp: In function ‘int main(int, char**)’:
/home/jessie/Desktop/mvs-texturing/apps/texrecon/texrecon.cpp:110:42: warning: catching polymorphic type ‘class util::FileException’ by value [-Wcatch-value=]
  110 |             } catch (util::FileException e) {
      |                                          ^
[100%] Linking CXX executable texrecon
/usr/bin/ld: CMakeFiles/texrecon.dir/texrecon.cpp.o: in function `tbb::task_scheduler_init::~task_scheduler_init()':
/usr/local/include/tbb/task_scheduler_init.h:128: undefined reference to `tbb::task_scheduler_init::terminate()'
/usr/bin/ld: CMakeFiles/texrecon.dir/texrecon.cpp.o: in function `tbb::task_scheduler_init::task_scheduler_init(int, unsigned long)':
/usr/local/include/tbb/task_scheduler_init.h:122: undefined reference to `tbb::task_scheduler_init::initialize(int, unsigned long)'
...

Stuck with the same problem :( I'm using: Ubuntu 18.04 tbb 2020.1-2 installed from sudo apt-get install libtbb-dev tried tbb from earlier release but tbb_config.cmake file is not found after compiling. And I could not find tbb in /usr/local/include after sudo apt-get install libtbb-dev

Could you please give me some advice about this? Thanks

CodeAunt commented 2 years ago

@pavan4 Hi, I also failed to compile this on ubuntu 18.04 docker container. Could you please help with the configure process about:

pinned all the repositories to old versions (for tbb etc.,.)"

I'm using:

$ apt list libtbb-dev
libtbb-dev/bionic,now 2017~U7-8 arm64
pavan4 commented 2 years ago

@CodeAunt I'll leave a dockerfile here for you to create a reproducible build. Hopefully, this helps you

FROM ubuntu:18.04
ENV DEBIAN_FRONTEND noninteractive

RUN apt-get -qq update && apt-get -y -qq install \
    cmake \
    build-essential \
    libpng-dev \
    libjpeg-dev \
    libtiff-dev \
    libtbb-dev \
    git \
    freeglut3-dev \
    libglib2.0-0

RUN git clone https://github.com/nmoehrle/mvs-texturing.git
RUN cd mvs-texturing && mkdir build && cd build && \
    cmake .. && \
    make -j && make install

I'm not sure what machine you are using or what your error is. You can change the base to 20.04 as well (I have tried and tested both)

CodeAunt commented 2 years ago

@pavan4 Thanks, I have built it successfully on an arm64 device by removing -mfpmath=sse and other similar options in CMakeLists and Makefiles. The docker file will help me on x64 devices later🙏🏻.

$ git diff CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0006c0..a2d4bc9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,10 +1,11 @@
 cmake_minimum_required(VERSION 3.1)

-LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/elibs/tbb")
-
 project(Texturing)
 include(ExternalProject)

+LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/elibs/tbb")
+find_package(TBB REQUIRED)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0006c0..a2d4bc9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,10 +1,11 @@
 cmake_minimum_required(VERSION 3.1)

-LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/elibs/tbb")
-
 project(Texturing)
 include(ExternalProject)

+LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/elibs/tbb")
+find_package(TBB REQUIRED)
 include(ExternalProject)

+LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/elibs/tbb")
+find_package(TBB REQUIRED)
+
 if(NOT CMAKE_BUILD_TYPE)
     message(STATUS "Setting build type to 'RELWITHDEBINFO' as none was specified.")
     set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
@@ -13,7 +14,6 @@ endif()
 #Search for TBB library (release build)
 set(CMAKE_BUILD_TYPE_BACKUP ${CMAKE_BUILD_TYPE})
 set(CMAKE_BUILD_TYPE RELEASE)
-FIND_PACKAGE(TBB REQUIRED)
 set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_BACKUP})

 set(CMAKE_CXX_STANDARD 11)
@@ -29,13 +29,14 @@ endif()

 if(CMAKE_COMPILER_IS_GNUCXX)
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Wundef -pedantic")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse -funroll-loops")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops")
 endif()

 find_package(PNG REQUIRED)
 find_package(JPEG REQUIRED)
 find_package(TIFF REQUIRED)

 add_subdirectory(elibs)
 include_directories(SYSTEM
     ${CMAKE_SOURCE_DIR}/elibs/rayint/libs