Skip to content

Will not compile on Ubuntu 14.04 (C++98 error etc.) #40

@kozuch

Description

@kozuch

I am trying to get the library working on Ubuntu 14.04. I upgraded my cmake from 2.8 to 3.2.2 (installed via PPA according to this post - https://askubuntu.com/a/610352/133573) but the library will not compile. For make i get this error:

Scanning dependencies of target SfMToyLibrary
[ 14%] Building CXX object SfMToyLib/CMakeFiles/SfMToyLibrary.dir/SfMCommon.cpp.o
In file included from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:28:0:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.h:211:5: error: in C++98 ‘sfmtoylib::Colors::WHEEL’ must be initialized by constructor, not by ‘{...}’
};
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.h:211:5: error: could not convert ‘{sfmtoylib::Colors::BLUE, sfmtoylib::Colors::AQUA, sfmtoylib::Colors::CYAN, sfmtoylib::Colors::MARINE, sfmtoylib::Colors::GREEN, sfmtoylib::Colors::LIME, sfmtoylib::Colors::YELLOW, sfmtoylib::Colors::ORANGE, sfmtoylib::Colors::RED, sfmtoylib::Colors::BEIGE, sfmtoylib::Colors::PURPLE, sfmtoylib::Colors::DEEP, sfmtoylib::Colors::BLACK}’ from ‘’ to ‘const std::vector<cv::Scalar_ >’
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp: In function ‘void sfmtoylib::KeyPointsToPoints(const Keypoints&, sfmtoylib::Points2f&)’:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:91:22: error: ISO C++ forbids declaration of ‘kp’ with no type [-fpermissive]
for (const auto& kp : kps) {
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:91:27: error: range-based ‘for’ loops are not allowed in C++98 mode
for (const auto& kp : kps) {
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:92:25: error: request for member ‘pt’ in ‘kp’, which is of non-class type ‘const int’
ps.push_back(kp.pt);
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp: In function ‘void sfmtoylib::PointsToKeyPoints(const Points2f&, sfmtoylib::Keypoints&)’:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:104:22: error: ISO C++ forbids declaration of ‘p’ with no type [-fpermissive]
for (const auto& p : ps) {
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:104:26: error: range-based ‘for’ loops are not allowed in C++98 mode
for (const auto& p : ps) {
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:105:39: error: no matching function for call to ‘cv::KeyPoint::KeyPoint(const int&, float)’
kps.push_back(KeyPoint(p, 1.0f));
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:105:39: note: candidates are:
In file included from /usr/local/include/opencv2/core.hpp:58:0,
from /usr/local/include/opencv2/core/core.hpp:48,
from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.h:31,
from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfMCommon.cpp:28:
/usr/local/include/opencv2/core/types.hpp:2223:1: note: cv::KeyPoint::KeyPoint(float, float, float, float, float, int, int)
KeyPoint::KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id)
^
/usr/local/include/opencv2/core/types.hpp:2223:1: note: candidate expects 7 arguments, 2 provided
/usr/local/include/opencv2/core/types.hpp:2219:1: note: cv::KeyPoint::KeyPoint(cv::Point2f, float, float, float, int, int)
KeyPoint::KeyPoint(Point2f _pt, float _size, float _angle, float _response, int _octave, int class_id)
^
/usr/local/include/opencv2/core/types.hpp:2219:1: note: no known conversion for argument 1 from ‘const int’ to ‘cv::Point2f {aka cv::Point
}’
/usr/local/include/opencv2/core/types.hpp:2215:1: note: cv::KeyPoint::KeyPoint()
KeyPoint::KeyPoint()
^
/usr/local/include/opencv2/core/types.hpp:2215:1: note: candidate expects 0 arguments, 2 provided
/usr/local/include/opencv2/core/types.hpp:641:27: note: cv::KeyPoint::KeyPoint(const cv::KeyPoint&)
class CV_EXPORTS_W_SIMPLE KeyPoint
^
/usr/local/include/opencv2/core/types.hpp:641:27: note: candidate expects 1 argument, 2 provided
make[2]: *** [SfMToyLib/CMakeFiles/SfMToyLibrary.dir/SfMCommon.cpp.o] Error 1
make[1]: *** [SfMToyLib/CMakeFiles/SfMToyLibrary.dir/all] Error 2
make: *** [all] Error 2

I even tried to inject lines for C++11 support from the main CMakeLists.txt to SfMToyLib/CMakeLists.txt but that did not help (inserted just after cmake version check)):
set(CXX_STANDARD 11)
set(CXX_STANDARD_REQUIRED ON)

This is my cmake output:

cmake -G "Unix Makefiles" ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- 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
-- Found OpenCV: /usr/local (found suitable version "3.2.0", minimum required is "3.1") found components: core calib3d features2d imgproc highgui
-- Boost version: 1.54.0
-- Found the following Boost libraries:
-- system
-- chrono
-- filesystem
-- unit_test_framework
-- program_options
-- Found required Ceres dependency: Eigen version 3.2.0 in /usr/include/eigen3
-- Found required Ceres dependency: glog
-- Performing Test GFLAGS_IN_GOOGLE_NAMESPACE
-- Performing Test GFLAGS_IN_GOOGLE_NAMESPACE - Success
-- Found required Ceres dependency: gflags
-- Found Ceres version: 1.12.0 installed in: /usr/local with components: [LAPACK, SuiteSparse, SparseLinearAlgebraLibrary, CXSparse, SchurSpecializations, OpenMP]
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kozuch/smf/SfM-Toy-Library-master/build

Can someone help me please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions