isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.12k stars 2.26k forks source link

Cannot Compile on Ubuntu 18.04 Server via Headless Building Instructions #5955

Open ZhiyeTang opened 1 year ago

ZhiyeTang commented 1 year ago

Checklist

Steps to reproduce the issue

I've downloaded the code from https://github.com/isl-org/Open3D/releases/tag/v0.16.0 .

Since I'm using a headless Ubuntu 18.04 server, I have to build the binary file on my own following the instructions here: http://www.open3d.org/docs/release/tutorial/visualization/headless_rendering.html .

The makefile seems generated well and no errors reported, but something goes wrong in the following step: make -j$(nproc):

Makefile:155: recipe for target 'all' failed make: *** [all] Error 2

I was using CMake from my Anaconda environment so firstly I supposed that it's a package-missing error, so I installed the corresponding packages in Anaconda: Mesalib, Glew and Glfw and retried command make -j$(nproc). But the error still occurs. After several retries, I found that the error might because of the failed from building assimp(The total error message is shown below). And it seems that no similar former issues can help.

Error message

In file included from /home/zhiyetang/data/Open3D-0.16.0/3rdparty/glew/src/glew.c:34:
/home/zhiyetang/data/Open3D-0.16.0/3rdparty/glew/include/GL/glew.h:1205:14: fatal error: GL/glu.h: No such file or directory
 1205 | #    include <GL/glu.h>
      |              ^~~~~~~~~~
compilation terminated.
CMakeFiles/3rdparty_glew.dir/build.make:75: recipe for target 'CMakeFiles/3rdparty_glew.dir/3rdparty/glew/src/glew.c.o' failed
make[2]: *** [CMakeFiles/3rdparty_glew.dir/3rdparty/glew/src/glew.c.o] Error 1
CMakeFiles/Makefile2:1014: recipe for target 'CMakeFiles/3rdparty_glew.dir/all' failed
make[1]: *** [CMakeFiles/3rdparty_glew.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 29%] Built target ext_uvatlas
[ 30%] Built target ext_curl
[ 31%] Built target ext_libpng
[ 33%] Built target 3rdparty_qhull_r
[ 36%] Built target shader
[  8%] Built target zlibstatic
Consolidate compiler generated dependencies of target assimp
[  9%] Building CXX object code/CMakeFiles/assimp.dir/AssetLib/SMD/SMDLoader.cpp.o
[ 10%] Building CXX object code/CMakeFiles/assimp.dir/AssetLib/X3D/X3DImporter_Geometry2D.cpp.o
In file included from /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/x86_64-conda-linux-gnu/bits/c++allocator.h:33,
                 from /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/allocator.h:46,
                 from /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/string:41,
                 from /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/include/assimp/types.h:78,
                 from /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter_Node.hpp:51,
                 from /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter.hpp:44,
                 from /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp:49:
In member function 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = aiVector3t<float>; _Args = {const aiVector3t<float>&}; _Tp = std::_List_node<aiVector3t<float> >]',
    inlined from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = aiVector3t<float>; _Args = {const aiVector3t<float>&}; _Tp = std::_List_node<aiVector3t<float> >]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/alloc_traits.h:516:17,
    inlined from 'std::__cxx11::list<_Tp, _Alloc>::_Node* std::__cxx11::list<_Tp, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const aiVector3t<float>&}; _Tp = aiVector3t<float>; _Alloc = std::allocator<aiVector3t<float> >]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_list.h:713:33,
    inlined from 'void std::__cxx11::list<_Tp, _Alloc>::_M_insert(iterator, _Args&& ...) [with _Args = {const aiVector3t<float>&}; _Tp = aiVector3t<float>; _Alloc = std::allocator<aiVector3t<float> >]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_list.h:2005:32,
    inlined from 'void std::__cxx11::list<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = aiVector3t<float>; _Alloc = std::allocator<aiVector3t<float> >]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_list.h:1306:24,
    inlined from 'void Assimp::X3DImporter::readDisk2D(Assimp::XmlNode&)' at /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp:277:28:
/home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/new_allocator.h:175:11: error: array subscript 'const aiVector3t<float>[1]' is partly outside array bounds of 'std::__cxx11::list<aiVector3t<float> > [1]' [-Werror=array-bounds]
  175 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp: In member function 'void Assimp::X3DImporter::readDisk2D(Assimp::XmlNode&)':
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp:239:40: note: at offset 16 into object 'tlist_i' of size 24
  239 |         std::list<aiVector3D> tlist_o, tlist_i;
      |                                        ^~~~~~~
In member function 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = aiVector3t<float>; _Args = {const aiVector3t<float>&}; _Tp = std::_List_node<aiVector3t<float> >]',
    inlined from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = aiVector3t<float>; _Args = {const aiVector3t<float>&}; _Tp = std::_List_node<aiVector3t<float> >]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/alloc_traits.h:516:17,
    inlined from 'std::__cxx11::list<_Tp, _Alloc>::_Node* std::__cxx11::list<_Tp, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const aiVector3t<float>&}; _Tp = aiVector3t<float>; _Alloc = std::allocator<aiVector3t<float> >]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_list.h:713:33,
    inlined from 'void std::__cxx11::list<_Tp, _Alloc>::_M_insert(iterator, _Args&& ...) [with _Args = {const aiVector3t<float>&}; _Tp = aiVector3t<float>; _Alloc = std::allocator<aiVector3t<float> >]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_list.h:2005:32,
    inlined from 'void std::__cxx11::list<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = aiVector3t<float>; _Alloc = std::allocator<aiVector3t<float> >]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_list.h:1306:24,
    inlined from 'void Assimp::X3DImporter::readDisk2D(Assimp::XmlNode&)' at /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp:278:28:
/home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/new_allocator.h:175:11: error: array subscript 'const aiVector3t<float>[1]' is partly outside array bounds of 'std::__cxx11::list<aiVector3t<float> > [1]' [-Werror=array-bounds]
  175 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp: In member function 'void Assimp::X3DImporter::readDisk2D(Assimp::XmlNode&)':
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/X3D/X3DImporter_Geometry2D.cpp:239:31: note: at offset 16 into object 'tlist_o' of size 24
  239 |         std::list<aiVector3D> tlist_o, tlist_i;
      |                               ^~~~~~~
cc1plus: all warnings being treated as errors
code/CMakeFiles/assimp.dir/build.make:2329: recipe for target 'code/CMakeFiles/assimp.dir/AssetLib/X3D/X3DImporter_Geometry2D.cpp.o' failed
make[5]: *** [code/CMakeFiles/assimp.dir/AssetLib/X3D/X3DImporter_Geometry2D.cpp.o] Error 1
make[5]: *** Waiting for unfinished jobs....
In file included from /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/vector:70,
                 from /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/include/assimp/DefaultLogger.hpp:57,
                 from /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/include/assimp/fast_atof.h:30,
                 from /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp:49:
In member function 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {unsigned int}; _Tp = unsigned int; _Alloc = std::allocator<unsigned int>]',
    inlined from 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = unsigned int; _Alloc = std::allocator<unsigned int>]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_vector.h:1294:21,
    inlined from 'void Assimp::SMDImporter::CreateOutputMeshes()' at /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp:256:50:
/home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/vector.tcc:114:27: error: array subscript 4294967295 is outside array bounds of 'void [103079215088]' [-Werror=array-bounds]
  114 |         if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
      |             ~~~~~~~~~~~~~~^~~~~~~~~
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp: In member function 'void Assimp::SMDImporter::CreateOutputMeshes()':
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp:241:57: note: at offset 103079215088 into object of size [8, 103079215088] allocated by 'operator new []'
  241 |     FaceList* aaiFaces = new FaceList[pScene->mNumMeshes];
      |                                                         ^
In member function 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {unsigned int}; _Tp = unsigned int; _Alloc = std::allocator<unsigned int>]',
    inlined from 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = unsigned int; _Alloc = std::allocator<unsigned int>]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_vector.h:1294:21,
    inlined from 'void Assimp::SMDImporter::CreateOutputMeshes()' at /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp:256:50:
/home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/vector.tcc:114:54: error: array subscript 4294967295 is outside array bounds of 'void [103079215088]' [-Werror=array-bounds]
  114 |         if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
      |                                        ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp: In member function 'void Assimp::SMDImporter::CreateOutputMeshes()':
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp:241:57: note: at offset 103079215088 into object of size [8, 103079215088] allocated by 'operator new []'
  241 |     FaceList* aaiFaces = new FaceList[pScene->mNumMeshes];
      |                                                         ^
In member function 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {unsigned int}; _Tp = unsigned int; _Alloc = std::allocator<unsigned int>]',
    inlined from 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = unsigned int; _Alloc = std::allocator<unsigned int>]' at /home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/stl_vector.h:1294:21,
    inlined from 'void Assimp::SMDImporter::CreateOutputMeshes()' at /home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp:256:50:
/home/zhiyetang/anaconda3/envs/6dof/x86_64-conda-linux-gnu/include/c++/12.2.0/bits/vector.tcc:119:13: error: array subscript 4294967295 is outside array bounds of 'void [103079215088]' [-Werror=array-bounds]
  119 |             ++this->_M_impl._M_finish;
      |             ^~
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp: In member function 'void Assimp::SMDImporter::CreateOutputMeshes()':
/home/zhiyetang/data/Open3D-0.16.0/build/assimp/src/ext_assimp/code/AssetLib/SMD/SMDLoader.cpp:241:57: note: at offset 103079215088 into object of size [8, 103079215088] allocated by 'operator new []'
  241 |     FaceList* aaiFaces = new FaceList[pScene->mNumMeshes];
      |                                                         ^
cc1plus: all warnings being treated as errors
code/CMakeFiles/assimp.dir/build.make:2231: recipe for target 'code/CMakeFiles/assimp.dir/AssetLib/SMD/SMDLoader.cpp.o' failed
make[5]: *** [code/CMakeFiles/assimp.dir/AssetLib/SMD/SMDLoader.cpp.o] Error 1
CMakeFiles/Makefile2:168: recipe for target 'code/CMakeFiles/assimp.dir/all' failed
make[4]: *** [code/CMakeFiles/assimp.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make[3]: *** [all] Error 2
CMakeFiles/ext_assimp.dir/build.make:85: recipe for target 'assimp/src/ext_assimp-stamp/ext_assimp-build' failed
make[2]: *** [assimp/src/ext_assimp-stamp/ext_assimp-build] Error 2
CMakeFiles/Makefile2:936: recipe for target 'CMakeFiles/ext_assimp.dir/all' failed
make[1]: *** [CMakeFiles/ext_assimp.dir/all] Error 2
Makefile:155: recipe for target 'all' failed
make: *** [all] Error 2

Open3D, Python and System information

- Operating system: Ubuntu 18.04 Server
- Python version: Python 3.8.15
- Open3D version: Open3D 0.16.0
- System architecture: x86
- Is this a remote workstation?: yes
- How did you install Open3D?: build from source
- Compiler version (if built from source): conda-forge gcc 12.2.0-19

Additional information

No response

ZhiyeTang commented 1 year ago

It seems that my C compiler cannot detect the file GL/glu.h. I've tried the fix offered in https://github.com/isl-org/Open3D/issues/4741 , installing package libglu but it doesn't work for me.

nanotuxi commented 1 year ago

Had the same error trying to compile from source today. Solution for me was: "cd" to the root of open3d and do a "git status" Git showed me some missing files, which could easily be restored with "git restore <path/filename>". That happened only once. After restoring all missing files the sources compiled correctly. That happened on Ubuntu 20.04 desktop (laptop)

ZhiyeTang commented 1 year ago

Thanks for your suggestion @nanotuxi . I downloaded the codes directly from the GitHub released page, which is not a Git repository. Thus, I tried to clone the master branch and rebuild it following the instruction. Then the same error occurs. Then I tried git status, but it says my branch is up to date which probably means there's no file missing. But the error log shows that the 3rdparty package glew inside directory Open3D/3rdparty/ missing the head file GL/glu.h, which is weird. I think that the glu.h will be generated if all the compilations are processed correctly, but I don't know how to trouble shoot. Anyway, Thanks a lot. Furthermore, can you please have a check at your Open3D/3rdparty/glew/include/GL directory, see whether there's a glu.h?

ZhiyeTang commented 1 year ago

I search for the head file glu.h, and an issue from glew shows that the head file is no longer required when building and running glew: https://github.com/nigels-com/glew/issues/192 . Therefore, I comment the including lines but another missing file error occured:

/home/zhiyetang/data/Open3D/3rdparty/glew/src/glew.c:41:12: fatal error: GL/osmesa.h: No such file or directory
   41 | #  include <GL/osmesa.h>
      |            ^~~~~~~~~~~~~
compilation terminated.
nitin-ppnp commented 1 year ago

Any progress here? I am facing the same issue.

vincentcartillier commented 1 year ago

I've had the same issue. I am on a headless server running Ubuntu 20 without sudo. So installing libglu1-mesa-dev from apt was not an option.

Instead compiling libglu from source was the solution.

You can download the source code here: https://launchpad.net/ubuntu/+source/libglu

Here is an example on how to proceed (Ubuntu 20):

cd /dir/where/you/want/to/install/glu
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/libglu/9.0.1-1build1/libglu_9.0.1.orig.tar.gz
tar xf libglu_9.0.1.orig.tar.gz
cd glu-9.0.1
./configure --prefix="$(pwd)/install/"
make
make install

Then don't forget to link the header files:

export CPATH=/path/to/your/libglu/install/include/:$CPATH

Then run make again and this should work.

Note that I had a further error related to LLVM afterwards:

/usr/bin/ld: /lib/x86_64-linux-gnu/libedit.so.2: undefined reference to `tgetnum@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libLLVM-12.so.1: undefined reference to `tigetnum@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libLLVM-12.so.1: undefined reference to `del_curterm@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libedit.so.2: undefined reference to `tputs@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libLLVM-12.so.1: undefined reference to `set_curterm@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libLLVM-12.so.1: undefined reference to `setupterm@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libedit.so.2: undefined reference to `tgoto@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libedit.so.2: undefined reference to `tgetent@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libedit.so.2: undefined reference to `tgetstr@NCURSES6_TINFO_5.0.19991023'
/usr/bin/ld: /lib/x86_64-linux-gnu/libedit.so.2: undefined reference to `tgetflag@NCURSES6_TINFO_5.0.19991023'

To solve this I had to run cmake with -DCMAKE_CXX_FLAGS="-frtti -lz -ltinfo"

See this and this for reference.