gptoolbox icon indicating copy to clipboard operation
gptoolbox copied to clipboard

Compiling mex on Linux/Ubuntu - Could NOT find MPFR and other issues

Open albertotono opened this issue 3 years ago • 8 comments

Dear Alec,

Thanks again for this great work.

I am trying to compile mex for Linux for the SGI workshop

Using matlab 2021a and (gptoolbox was installed via matlab-addon: /home/alberto/MATLAB Add-Ons/Collections/gptoolbox)

currently I tried both

cmake .. cmake ../ -DMatlab_ROOT_DIR=/usr/local/MATLAB/R2021a on the build folder

In attached the log and error files, it is outputting this folder structure with empty folders Screenshot from 2021-07-18 13-27-42

It seems there is an issue with

CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find MPFR (missing: MPFR_LIBRARIES MPFR_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  external/libigl/external/cgal/Installation/cmake/modules/FindMPFR.cmake:53 (find_package_handle_standard_args)
  external/libigl/external/cgal/Installation/cmake/modules/CGAL_SetupGMP.cmake:21 (find_package)
  external/libigl/external/cgal/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake:41 (include)
  external/libigl/external/cgal/Installation/lib/cmake/CGAL/CGALConfig.cmake:106 (include)
  external/libigl/external/cgal/CGALConfig.cmake:6 (include)
  external/libigl/cmake/libigl.cmake:233 (find_package)
  cmake/FindLIBIGL.cmake:35 (include)
  CMakeLists.txt:78 (find_package)

Maybe related with this one https://github.com/PyMesh/PyMesh/issues/96

so I performed

  • sudo apt install libcgal-dev
  • sudo apt install libcgal-demo
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test COMPILER_SUPPORTS_MARCH_NATIVE
-- Performing Test COMPILER_SUPPORTS_MARCH_NATIVE - Success
-- Found Matlab: /usr/local/MATLAB/R2021a/extern/include (found version "9.10") found components: MEX_COMPILER MX_LIBRARY ENG_LIBRARY 
-- Found LIBIGL: /home/alberto/MATLAB Add-Ons/Collections/gptoolbox/mex/external/libigl/include  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- 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  
-- Creating target: igl::core (igl)
BOOST_ROOT: 
-- Using header-only CGAL
-- Targetting Unix Makefiles
-- Using /usr/bin/c++ compiler.
-- Found GMP: /usr/lib/x86_64-linux-gnu/libgmp.so  
-- Found MPFR: /usr/lib/x86_64-linux-gnu/libmpfr.so  
-- __cplusplus is 201402
--   --> Do not link with Boost.Thread
-- Found Boost 1.70.0 at /home/alberto/anaconda3/lib/cmake/Boost-1.70.0
--   Requested configuration: QUIET REQUIRED
-- Found boost_headers 1.70.0 at /home/alberto/anaconda3/lib/cmake/boost_headers-1.70.0
-- Found Boost: /home/alberto/anaconda3/lib/cmake/Boost-1.70.0/BoostConfig.cmake (found suitable version "1.70.0", minimum required is "1.48")  
-- Boost include dirs: /home/alberto/anaconda3/include
-- Boost libraries:    
-- Found Boost 1.70.0 at /home/alberto/anaconda3/lib/cmake/Boost-1.70.0
--   Requested configuration: QUIET REQUIRED COMPONENTS thread;system
-- Found boost_thread 1.70.0 at /home/alberto/anaconda3/lib/cmake/boost_thread-1.70.0
-- No suitable boost_thread variant has been identified!
--   libboost_thread.so.1.70.0 (shared, BUILD_SHARED_LIBS not ON, set Boost_USE_STATIC_LIBS=OFF to override)
--   libboost_thread.a (static, Boost_USE_STATIC_LIBS=OFF)
CMake Error at /home/alberto/anaconda3/lib/cmake/Boost-1.70.0/BoostConfig.cmake:95 (find_package):
  Found package configuration file:

    /home/alberto/anaconda3/lib/cmake/boost_thread-1.70.0/boost_thread-config.cmake

  but it set boost_thread_FOUND to FALSE so package "boost_thread" is
  considered to be NOT FOUND.  Reason given by package:

  No suitable build variant has been found.

Call Stack (most recent call first):
  /home/alberto/anaconda3/lib/cmake/Boost-1.70.0/BoostConfig.cmake:124 (boost_find_dependency)
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:443 (find_package)
  external/libigl/external/cgal/Installation/cmake/modules/CGAL_SetupCGAL_CoreDependencies.cmake:59 (find_package)
  external/libigl/external/cgal/Installation/lib/cmake/CGAL/CGALConfig.cmake:106 (include)
  external/libigl/external/cgal/CGALConfig.cmake:6 (include)
  external/libigl/cmake/libigl.cmake:233 (find_package)
  cmake/FindLIBIGL.cmake:35 (include)
  CMakeLists.txt:78 (find_package)

I have installed boost and set the path export BOOST_ROOT=/home/alberto/Documents/boost/boost_1_76_0

Should I install manually all the other libraries or this is supposed to support all of them (stl, Eigen libigl, CGAL, Embree,El Topo.) already?

CMakeError.log CMakeOutput.log

Any help would be much appreciated.

albertotono avatar Jul 18 '21 20:07 albertotono

I think you might need to do something like

sudo apt-get install mpfr gmp

alecjacobson avatar Jul 18 '21 20:07 alecjacobson

Thank you so much for the quick reply. yes, I used the sudo apt-get install libmpfr-dev and sudo apt-get install libgmp-dev before.

Do you know someone who have already compiled mex on Linux successfully?

albertotono avatar Jul 18 '21 21:07 albertotono

I did it recently and vaguely remember that CGAL makes it cumbersome to tell it where to find MPFR and gmp. I'll dig through my command history to see if I can find what I did.

alecjacobson avatar Jul 18 '21 21:07 alecjacobson

I found this:

cmake ../ -DCMAKE_BUILD_TYPE=Release -DGMP_INCLUDE_DIR=pwd/../external/gmp-6.2.0 -DGMP_LIBRARIES=pwd/../external/gmp-6.2.0/build/lib/libgmp.so -DMPFR_INCLUDE_DIR=pwd/../external/mpfr-4.0.2/build/include -DMPFR_LIBRARIES=pwd/../external/mpfr-4.0.2/build/lib/libmpfr.a -DLIBIGL_WITH_CGAL=ON

On Sun, Jul 18, 2021 at 5:12 PM Alec Jacobson @.***> wrote:

I did it recently and vaguely remember that CGAL makes it cumbersome to tell it where to find MPFR and gmp. I'll dig through my command history to see if I can find what I did.

alecjacobson avatar Jul 18 '21 21:07 alecjacobson

I think I was on a machine where I couldn't use apt-get so I downloaded/installed mpfr and gmp in the external folder of libigl. Maybe this also works if you point it to /usr/local/ or wherever your mpfr gmp are .

alecjacobson avatar Jul 18 '21 21:07 alecjacobson

Thank you so much.

Yes, now I don't have that error about MPFR anymore

I had also a conflict with different boost version before ( one in anaconda and another one 1.70 and 1.76) . I was able to solve that (mayybe)

Now the build folder looks like this

Screenshot from 2021-07-18 14-22-58

and the external Screenshot from 2021-07-18 14-23-21

Not sure what is the specific error that I am getting. CMakeError.log CMakeOutput.log

as far as I am reading the pthread shouldn't be an issue

Would you be able to share your notes with us about the linux installation?

We are doing our best to make sure students will be able to install it as well https://github.com/odedstein/sgi-introduction-course/blob/main/205_mex/compilation_instructions.md.

Any help would be much appreciated.

albertotono avatar Jul 18 '21 21:07 albertotono

It seems it was missing also this

sudo apt-get install liblapack-dev

Using cmake-gui It seems working now

Screenshot from 2021-07-18 14-38-36

also on make Screenshot from 2021-07-18 14-39-28

albertotono avatar Jul 18 '21 21:07 albertotono

ooffff. Glad you made it through. If you have a suggestion of how to give better instructions for linux uses, please share.

alecjacobson avatar Jul 19 '21 00:07 alecjacobson