chrisyu-cs / repulsive-curves

MIT License
190 stars 23 forks source link

Compilation Error on WSL #5

Open BradyAJohnston opened 3 years ago

BradyAJohnston commented 3 years ago

I'm excited to be able to try and use this software - but I am having trouble with the compilation step. Trying to compile on WSL on (Version 4.4.0-18362-Microsoft) and Ubuntu:

NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"

After tinkering around for a long time making sure I have sufficient packages install and ready to go, it was making good progress but now gets the series of errors below, which seem to be actual code related? Any help would be appreciated!

Using clang 10.0.0 :

cmake run:

$ cmake -DCMAKE_C_COMPILER=clang ..
-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- 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
-- cmake build type: Release
Using clang/gcc compiler flags
Setting gcc-specific options
-- Building STATIC libraries
-- 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
-- Found BLAS: /usr/lib/x86_64-linux-gnu/libblas.so
-- Found AMD library: /usr/lib/x86_64-linux-gnu/libamd.so
-- Found AMD header in: /usr/include/suitesparse
-- Found CAMD library: /usr/lib/x86_64-linux-gnu/libcamd.so
-- Found CAMD header in: /usr/include/suitesparse
-- Found COLAMD library: /usr/lib/x86_64-linux-gnu/libcolamd.so
-- Found COLAMD header in: /usr/include/suitesparse
-- Found CCOLAMD library: /usr/lib/x86_64-linux-gnu/libccolamd.so
-- Found CCOLAMD header in: /usr/include/suitesparse
-- Found CHOLMOD library: /usr/lib/x86_64-linux-gnu/libcholmod.so
-- Found CHOLMOD header in: /usr/include/suitesparse
-- Found SuiteSparseQR library: /usr/lib/x86_64-linux-gnu/libspqr.so
-- Found SuiteSparseQR header in: /usr/include/suitesparse
-- Did not find Intel TBB library, assuming SuiteSparseQR was not compiled with TBB.
-- Found SuiteSparse_config library: /usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
-- Found SuiteSparse_config header in: /usr/include/suitesparse
-- Adding librt: /usr/lib/x86_64-linux-gnu/librt.so to SuiteSparse_config libraries (required on Linux & Unix [not OSX] if SuiteSparse is compiled with timing).
-- Did not find METIS library (optional SuiteSparse dependency)
-- Found SuiteSparse: TRUE (found version "5.7.1")
-- Found SuiteSparse 5.7.1, building with SuiteSparse.
-- Guesstimated umfpack location as: /usr/lib/x86_64-linux-gnu/libumfpack.so
-- Using X11 for window creation
-- Found X11: /usr/include
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bjohnston/git/repulsive-curves/build

Errors

$ make
Scanning dependencies of target stb
[  1%] Building CXX object deps/polyscope/deps/stb/CMakeFiles/stb.dir/stb_impl.cpp.o
[  2%] Linking CXX static library ../../../../lib/libstb.a
[  2%] Built target stb
Scanning dependencies of target glad
[  3%] Building C object deps/polyscope/deps/glad/src/CMakeFiles/glad.dir/glad.c.o
[  4%] Linking C static library ../../../../../lib/libglad.a
[  4%] Built target glad
Scanning dependencies of target glfw
[  5%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/context.c.o
[  6%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/init.c.o
[  6%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/input.c.o
[  7%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/monitor.c.o
[  8%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/vulkan.c.o
[  9%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/window.c.o
[ 10%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/x11_init.c.o
[ 11%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/x11_monitor.c.o
[ 11%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/x11_window.c.o
[ 12%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/xkb_unicode.c.o
[ 13%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/posix_time.c.o
[ 14%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/posix_thread.c.o
[ 15%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/glx_context.c.o
[ 15%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/egl_context.c.o
[ 16%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/osmesa_context.c.o
[ 17%] Building C object deps/polyscope/deps/glfw/src/CMakeFiles/glfw.dir/linux_joystick.c.o
[ 18%] Linking C static library ../../../../../lib/libglfw3.a
[ 18%] Built target glfw
Scanning dependencies of target imgui
[ 19%] Building CXX object deps/polyscope/deps/imgui/CMakeFiles/imgui.dir/imgui/imgui.cpp.o
[ 20%] Building CXX object deps/polyscope/deps/imgui/CMakeFiles/imgui.dir/imgui/imgui_draw.cpp.o
[ 20%] Building CXX object deps/polyscope/deps/imgui/CMakeFiles/imgui.dir/imgui/imgui_widgets.cpp.o
[ 21%] Building CXX object deps/polyscope/deps/imgui/CMakeFiles/imgui.dir/imgui/imgui_demo.cpp.o
[ 22%] Building CXX object deps/polyscope/deps/imgui/CMakeFiles/imgui.dir/imgui/examples/imgui_impl_glfw.cpp.o
[ 23%] Building CXX object deps/polyscope/deps/imgui/CMakeFiles/imgui.dir/imgui/examples/imgui_impl_opengl3.cpp.o
[ 24%] Linking CXX static library ../../../../lib/libimgui.a
[ 24%] Built target imgui
Scanning dependencies of target polyscope
[ 24%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/polyscope.cpp.o
[ 25%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/screenshot.cpp.o
[ 26%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/structure.cpp.o
[ 27%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/utilities.cpp.o
[ 28%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/view.cpp.o
[ 29%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/messages.cpp.o
[ 29%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/pick.cpp.o
[ 30%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/disjoint_sets.cpp.o
[ 31%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/file_helpers.cpp.o
[ 32%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/camera_parameters.cpp.o
[ 33%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/histogram.cpp.o
[ 34%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/gl/gl_utils.cpp.o
[ 34%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/gl/ground_plane.cpp.o
[ 35%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/gl/color_maps.cpp.o
[ 36%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/color_management.cpp.o
[ 37%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/gl/materials/bindata_concrete_seamless.cpp.o
[ 38%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/gl/materials/bindata_mat_wax.cpp.o
[ 38%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/gl/materials/materials.cpp.o
[ 39%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/binary_font_cousine_regular.cpp.o
[ 40%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/trace_vector_field.cpp.o
[ 41%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/ribbon_artist.cpp.o
[ 42%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/point_cloud.cpp.o
[ 43%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/point_cloud_color_quantity.cpp.o
[ 43%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/point_cloud_scalar_quantity.cpp.o
[ 44%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/point_cloud_vector_quantity.cpp.o
[ 45%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_mesh.cpp.o
[ 46%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_mesh_io.cpp.o
[ 47%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_scalar_quantity.cpp.o
[ 47%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_color_quantity.cpp.o
[ 48%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_distance_quantity.cpp.o
[ 49%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_vector_quantity.cpp.o
[ 50%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_count_quantity.cpp.o
[ 51%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_graph_quantity.cpp.o
[ 52%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/surface_parameterization_quantity.cpp.o
[ 52%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/curve_network.cpp.o
[ 53%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/curve_network_scalar_quantity.cpp.o
[ 54%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/curve_network_color_quantity.cpp.o
[ 55%] Building CXX object deps/polyscope/src/CMakeFiles/polyscope.dir/curve_network_vector_quantity.cpp.o
[ 56%] Linking CXX static library ../../../lib/libpolyscope.a
[ 56%] Built target polyscope
Scanning dependencies of target geometry-central
[ 56%] Building CXX object deps/geometry-central/src/CMakeFiles/geometry-central.dir/surface/halfedge_mesh.cpp.o
[ 57%] Building CXX object deps/geometry-central/src/CMakeFiles/geometry-central.dir/surface/halfedge_factories.cpp.o
[ 58%] Building CXX object deps/geometry-central/src/CMakeFiles/geometry-central.dir/surface/meshio.cpp.o
In file included from /home/bjohnston/git/repulsive-curves/deps/geometry-central/src/surface/meshio.cpp:8:
/home/bjohnston/git/repulsive-curves/deps/geometry-central/src/../deps/happly/happly.h: In instantiation of ‘std::vector<std::vector<_RealType> > happly::PLYData::getFaceIndices() [with T = long unsigned int]’:
/home/bjohnston/git/repulsive-curves/deps/geometry-central/src/surface/meshio.cpp:83:73:   required from here
/home/bjohnston/git/repulsive-curves/deps/geometry-central/src/../deps/happly/happly.h:1226:11: error: catching polymorphic type ‘class std::runtime_error’ by value [-Werror=catch-value=]
 1226 |         } catch (std::runtime_error e) {
      |           ^~~~~
/home/bjohnston/git/repulsive-curves/deps/geometry-central/src/../deps/happly/happly.h: In instantiation of ‘std::vector<std::vector<_RealType> > happly::Element::getListPropertyAnySign(const string&) [with T = long unsigned int; std::string = std::__cxx11::basic_string<char>]’:
/home/bjohnston/git/repulsive-curves/deps/geometry-central/src/../deps/happly/happly.h:1225:59:   required from ‘std::vector<std::vector<_RealType> > happly::PLYData::getFaceIndices() [with T = long unsigned int]’
/home/bjohnston/git/repulsive-curves/deps/geometry-central/src/surface/meshio.cpp:83:73:   required from here
/home/bjohnston/git/repulsive-curves/deps/geometry-central/src/../deps/happly/happly.h:795:7: error: catching polymorphic type ‘class std::runtime_erro ’ by value [-Werror=catch-value=]
  795 |     } catch (std::runtime_error orig_e) {
      |       ^~~~~
/home/bjohnston/git/repulsive-curves/deps/geometry-central/src/../deps/happly/happly.h:818:9: error: catching polymorphic type ‘class std::runtime_erro ’ by value [-Werror=catch-value=]
  818 |       } catch (std::runtime_error new_e) {
      |         ^~~~~
cc1plus: error: unrecognized command line option ‘-Wno-unused-private-field’ [-Werror]
cc1plus: error: unrecognized command line option ‘-Wno-return-std-move’ [-Werror]
cc1plus: all warnings being treated as errors
make[2]: *** [deps/geometry-central/src/CMakeFiles/geometry-central.dir/build.make:89: deps/geometry-central/src/CMakeFiles/geometry-central.dir/surface/meshio.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:414: deps/geometry-central/src/CMakeFiles/geometry-central.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
m5imunovic commented 3 years ago

The quickest way is to modify the lines 795, 818 and 1226 in /home/bjohnston/git/repulsive-curves/deps/geometry-central/src/../deps/happly/happly.h, respectively, to catch reference instead of value, i.e.: } catch (std::runtime_error& ...) { Alternatively, use more recent version of happly where this is fixed.

BradyAJohnston commented 2 years ago

Thanks for the advice, adjusting to the reference instead of values worked (had to catch a couple more errors later as well) but now when it gets to 100% it has one final error.

[100%] Linking CXX executable bin/rcurves_app
/home/linuxbrew/.linuxbrew/bin/ld: lib/libglad.a(glad.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/rcurves_app.dir/build.make:104: bin/rcurves_app] Error 1
make[1]: *** [CMakeFiles/Makefile2:322: CMakeFiles/rcurves_app.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

I have tried conducting the original cmake as follows:

cmake -DCMAKE_C_COMPILER=clang -D CMAKE_CXX_FLAGS="-fPIE" ..  

But I still get the same error. Would you have any more advice?

m5imunovic commented 2 years ago

https://stackoverflow.com/questions/38296756/what-is-the-idiomatic-way-in-cmake-to-add-the-fpic-compiler-option This topic explains how to set position independent code property either on the specific library or all targets. I tried adding the set(CMAKE_POSITION_INDEPENDENT_CODE ON) to top level CMakeLists.txt and it worked without errors. There is also mention about the command line option in the answers but haven't tried out that one.