felixendres / rgbdslam_v2

RGB-D SLAM for ROS
GNU General Public License v3.0
935 stars 399 forks source link

g2o build issue #82

Open bgyooPtr opened 6 years ago

bgyooPtr commented 6 years ago

Hello I have a problem building the dependency g2o. I am using Ubuntu 16.04, ros kinetic and opencv 3.2-dev.

First, I downloaded g2o and started the build using the build script (make_deb.sh). I got the following error:

In file included from /usr/include/c++/5/random:35:0, from /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:38, from /home/bgyoo/library/g2ofork/g2o/examples/data_fitting/curve_fit.cpp:30: /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

error This file requires compiler and library support \

^ In file included from /home/bgyoo/library/g2ofork/g2o/examples/data_fitting/curve_fit.cpp:30:0: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:44:71: error: ‘std::mt19937’ has not been declared double G2O_STUFF_API sampleUniform(double min=0, double max=1, std::mt19937 generator=0); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:45:39: error: ‘mt19937’ is not a member of ‘std’ double G2O_STUFF_API sampleGaussian(std::mt19937 generator = 0); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:45:53: error: ‘generator’ was not declared in this scope double G2O_STUFF_API sampleGaussian(std::mt19937 generator = 0); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:83:10: error: ‘mt19937’ in namespace ‘std’ does not name a type std::mt19937 _generator; ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h: In constructor ‘g2o::GaussianSampler<SampleType, CovarianceType>::GaussianSampler(bool)’: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:51:7: error: class ‘g2o::GaussianSampler<SampleType, CovarianceType>’ does not have any field named ‘_generator’ _generator(0) ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:54:9: error: ‘_generator’ was not declared in this scope _generator = new std::mt19937; ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:54:31: error: ‘mt19937’ in namespace ‘std’ does not name a type _generator = new std::mt19937; ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h: In destructor ‘g2o::GaussianSampler<SampleType, CovarianceType>::~GaussianSampler()’: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:58:14: error: ‘_generator’ was not declared in this scope delete _generator; ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h: In member function ‘SampleType g2o::GaussianSampler<SampleType, CovarianceType>::generateSample()’: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:70:17: error: ‘_generator’ was not declared in this scope s(i) = (_generator) ? sampleGaussian(_generator) : sampleGaussian(); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:70:56: error: ‘g2o::sampleGaussian’ cannot be used as a function s(i) = (_generator) ? sampleGaussian(_generator) : sampleGaussian(); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:70:75: error: ‘g2o::sampleGaussian’ cannot be used as a function s(i) = (_generator) ? sampleGaussian(_generator) : sampleGaussian(); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h: In member function ‘bool g2o::GaussianSampler<SampleType, CovarianceType>::seed(int)’: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:76:12: error: ‘_generator’ was not declared in this scope if (!_generator) ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:78:7: error: ‘_generator’ was not declared in this scope _generator->seed(s); ^ [ 44%] Linking CXX shared library ../../../../lib/libg2o_solver_eigen.so [ 44%] Built target solver_eigen Scanning dependencies of target create_sphere [ 44%] Building CXX object g2o/examples/sphere/CMakeFiles/create_sphere.dir/create_sphere.cpp.o In file included from /usr/include/c++/5/random:35:0, from /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:38, from /home/bgyoo/library/g2ofork/g2o/examples/sphere/create_sphere.cpp:37: /usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

error This file requires compiler and library support \

^ g2o/examples/data_fitting/CMakeFiles/curve_fit.dir/build.make:62: recipe for target 'g2o/examples/data_fitting/CMakeFiles/curve_fit.dir/curve_fit.cpp.o' failed make[2]: [g2o/examples/data_fitting/CMakeFiles/curve_fit.dir/curve_fit.cpp.o] Error 1 CMakeFiles/Makefile2:1940: recipe for target 'g2o/examples/data_fitting/CMakeFiles/curve_fit.dir/all' failed make[1]: [g2o/examples/data_fitting/CMakeFiles/curve_fit.dir/all] Error 2 make[1]: Waiting for unfinished jobs.... In file included from /home/bgyoo/library/g2ofork/g2o/examples/sphere/create_sphere.cpp:37:0: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:44:71: error: ‘std::mt19937’ has not been declared double G2O_STUFF_API sampleUniform(double min=0, double max=1, std::mt19937 generator=0); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:45:39: error: ‘mt19937’ is not a member of ‘std’ double G2O_STUFF_API sampleGaussian(std::mt19937 generator = 0); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:45:53: error: ‘generator’ was not declared in this scope double G2O_STUFF_API sampleGaussian(std::mt19937 generator = 0); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:83:10: error: ‘mt19937’ in namespace ‘std’ does not name a type std::mt19937* _generator; ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h: In constructor ‘g2o::GaussianSampler<SampleType, CovarianceType>::GaussianSampler(bool)’: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:51:7: error: class ‘g2o::GaussianSampler<SampleType, CovarianceType>’ does not have any field named ‘_generator’ _generator(0) ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:54:9: error: ‘_generator’ was not declared in this scope _generator = new std::mt19937; ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:54:31: error: ‘mt19937’ in namespace ‘std’ does not name a type _generator = new std::mt19937; ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h: In destructor ‘g2o::GaussianSampler<SampleType, CovarianceType>::~GaussianSampler()’: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:58:14: error: ‘_generator’ was not declared in this scope delete _generator; ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h: In member function ‘SampleType g2o::GaussianSampler<SampleType, CovarianceType>::generateSample()’: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:70:17: error: ‘_generator’ was not declared in this scope s(i) = (_generator) ? sampleGaussian(_generator) : sampleGaussian(); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:70:56: error: ‘g2o::sampleGaussian’ cannot be used as a function s(i) = (_generator) ? sampleGaussian(_generator) : sampleGaussian(); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:70:75: error: ‘g2o::sampleGaussian’ cannot be used as a function s(i) = (_generator) ? sampleGaussian(_generator) : sampleGaussian(); ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h: In member function ‘bool g2o::GaussianSampler<SampleType, CovarianceType>::seed(int)’: /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:76:12: error: ‘_generator’ was not declared in this scope if (!_generator) ^ /home/bgyoo/library/g2ofork/g2o/stuff/sampler.h:78:7: error: ‘_generator’ was not declared in this scope _generator->seed(s); ^ /home/bgyoo/library/g2ofork/g2o/examples/sphere/create_sphere.cpp: In function ‘int main(int, char*)’: /home/bgyoo/library/g2ofork/g2o/examples/sphere/create_sphere.cpp:157:5: error: ‘random_device’ is not a member of ‘std’ std::random_device r; ^ /home/bgyoo/library/g2ofork/g2o/examples/sphere/create_sphere.cpp:158:5: error: ‘seed_seq’ is not a member of ‘std’ std::seed_seq seedSeq{r(), r(), r(), r(), r()}; ^ /home/bgyoo/library/g2ofork/g2o/examples/sphere/create_sphere.cpp:160:5: error: ‘seedSeq’ was not declared in this scope seedSeq.generate(seeds.begin(), seeds.end()); ^ g2o/examples/sphere/CMakeFiles/create_sphere.dir/build.make:62: recipe for target 'g2o/examples/sphere/CMakeFiles/create_sphere.dir/create_sphere.cpp.o' failed make[2]: [g2o/examples/sphere/CMakeFiles/create_sphere.dir/create_sphere.cpp.o] Error 1 CMakeFiles/Makefile2:1999: recipe for target 'g2o/examples/sphere/CMakeFiles/create_sphere.dir/all' failed make[1]: *** [g2o/examples/sphere/CMakeFiles/create_sphere.dir/all] Error 2

So I enabled c ++ 11 and rebuilt it. and then I got the error:

CMakeFiles/create_sphere.dir/create_sphere.cpp.o: In function main': create_sphere.cpp:(.text.startup+0x1c96): undefined reference tog2o::sampleGaussian(std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>)' create_sphere.cpp:(.text.startup+0x1e2d): undefined reference to `g2o::sampleGaussian(std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>)' collect2: error: ld returned 1 exit status g2o/examples/sphere/CMakeFiles/create_sphere.dir/build.make:101: recipe for target '../bin/create_sphere' failed make[2]: [../bin/create_sphere] Error 1 CMakeFiles/Makefile2:1999: recipe for target 'g2o/examples/sphere/CMakeFiles/create_sphere.dir/all' failed make[1]: [g2o/examples/sphere/CMakeFiles/create_sphere.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs....

What is the fundamental solution?

felixendres commented 6 years ago

Edit: got the first answer wrong, sorry

The script make_deb.sh is not needed (I'll remove it to avoid confusion), just do the regular cmake based installation (mkdir build; cd build; cmake ..; make install). Even better, follow (or use) the installation script linked in the Readme file.