Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kozuch opened this issue Jul 6, 2017 · 4 comments
Open

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

kozuch opened this issue Jul 6, 2017 · 4 comments

Comments

@kozuch
Copy link
Contributor

kozuch commented Jul 6, 2017

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?

@kozuch
Copy link
Contributor Author

kozuch commented Jul 6, 2017

Looks like I got rid of the C++98 error with a hint of #cmake FreeNode IRC user who said there are CMAKE_ prefixes missing here:
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

It still wont compile though but I am getting a bunch of different errors now (related to boost):

make
Scanning dependencies of target SfMToyLibrary
[ 14%] Building CXX object SfMToyLib/CMakeFiles/SfMToyLibrary.dir/SfMCommon.cpp.o
[ 28%] Building CXX object SfMToyLib/CMakeFiles/SfMToyLibrary.dir/SfM.cpp.o
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp: In member function ‘bool sfmtoylib::SfM::setImagesDirectory(const string&)’:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: error: no matching function for call to ‘begin(boost::filesystem::directory_iterator&)’
for (directory_entry& x : directory_iterator(dirPath)) {
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: note: candidates are:
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/random:41,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
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/SfM.h:31,
from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:28:
/usr/include/c++/4.8/bits/range_access.h:87:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm])
begin(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.8/bits/range_access.h:87:5: note: template argument deduction/substitution failed:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: note: mismatched types ‘_Tp [_Nm]’ and ‘boost::filesystem::directory_iterator’
for (directory_entry& x : directory_iterator(dirPath)) {
^
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/random:41,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
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/SfM.h:31,
from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:28:
/usr/include/c++/4.8/bits/range_access.h:58:5: note: template decltype (__cont.begin()) std::begin(const _Container&)
begin(const _Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.8/bits/range_access.h:58:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template decltype (__cont.begin()) std::begin(const _Container&) [with _Container = boost::filesystem::directory_iterator]’:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: required from here
/usr/include/c++/4.8/bits/range_access.h:58:5: error: ‘const class boost::filesystem::directory_iterator’ has no member named ‘begin’
/usr/include/c++/4.8/bits/range_access.h:48:5: note: template decltype (__cont.begin()) std::begin(_Container&)
begin(_Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.8/bits/range_access.h:48:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template decltype (__cont.begin()) std::begin(_Container&) [with _Container = boost::filesystem::directory_iterator]’:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: required from here
/usr/include/c++/4.8/bits/range_access.h:48:5: error: ‘class boost::filesystem::directory_iterator’ has no member named ‘begin’
In file included from /usr/include/c++/4.8/utility:74:0,
from /usr/include/c++/4.8/algorithm:60,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
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/SfM.h:31,
from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:28:
/usr/include/c++/4.8/initializer_list:89:5: note: template constexpr const _Tp* std::begin(std::initializer_list<_Tp>)
begin(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.8/initializer_list:89:5: note: template argument deduction/substitution failed:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: note: ‘boost::filesystem::directory_iterator’ is not derived from ‘std::initializer_list<_Tp>’
for (directory_entry& x : directory_iterator(dirPath)) {
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: error: no matching function for call to ‘end(boost::filesystem::directory_iterator&)’
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: note: candidates are:
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/random:41,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
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/SfM.h:31,
from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:28:
/usr/include/c++/4.8/bits/range_access.h:97:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
end(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.8/bits/range_access.h:97:5: note: template argument deduction/substitution failed:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: note: mismatched types ‘_Tp [_Nm]’ and ‘boost::filesystem::directory_iterator’
for (directory_entry& x : directory_iterator(dirPath)) {
^
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/random:41,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
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/SfM.h:31,
from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:28:
/usr/include/c++/4.8/bits/range_access.h:78:5: note: template decltype (__cont.end()) std::end(const _Container&)
end(const _Container& __cont) -> decltype(__cont.end())
^
/usr/include/c++/4.8/bits/range_access.h:78:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template decltype (__cont.end()) std::end(const _Container&) [with _Container = boost::filesystem::directory_iterator]’:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: required from here
/usr/include/c++/4.8/bits/range_access.h:78:5: error: ‘const class boost::filesystem::directory_iterator’ has no member named ‘end’
/usr/include/c++/4.8/bits/range_access.h:68:5: note: template decltype (__cont.end()) std::end(_Container&)
end(_Container& __cont) -> decltype(__cont.end())
^
/usr/include/c++/4.8/bits/range_access.h:68:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of ‘template decltype (__cont.end()) std::end(_Container&) [with _Container = boost::filesystem::directory_iterator]’:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: required from here
/usr/include/c++/4.8/bits/range_access.h:68:5: error: ‘class boost::filesystem::directory_iterator’ has no member named ‘end’
In file included from /usr/include/c++/4.8/utility:74:0,
from /usr/include/c++/4.8/algorithm:60,
from /usr/local/include/opencv2/core/base.hpp:55,
from /usr/local/include/opencv2/core.hpp:54,
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/SfM.h:31,
from /home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:28:
/usr/include/c++/4.8/initializer_list:99:5: note: template constexpr const _Tp* std::end(std::initializer_list<_Tp>)
end(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.8/initializer_list:99:5: note: template argument deduction/substitution failed:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:107:57: note: ‘boost::filesystem::directory_iterator’ is not derived from ‘std::initializer_list<_Tp>’
for (directory_entry& x : directory_iterator(dirPath)) {
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp: In member function ‘void sfmtoylib::SfM::saveCloudAndCamerasToPLY(const string&)’:
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:636:18: error: variable ‘std::ofstream ofs’ has initializer but incomplete type
ofstream ofs(prefix + "_points.ply");
^
/home/kozuch/smf/SfM-Toy-Library-master/SfMToyLib/SfM.cpp:668:19: error: variable ‘std::ofstream ofsc’ has initializer but incomplete type
ofstream ofsc(prefix + "_cameras.ply");
^
make[2]: *** [SfMToyLib/CMakeFiles/SfMToyLibrary.dir/SfM.cpp.o] Error 1
make[1]: *** [SfMToyLib/CMakeFiles/SfMToyLibrary.dir/all] Error 2
make: *** [all] Error 2

@royshil
Copy link
Owner

royshil commented Jul 6, 2017 via email

@kozuch
Copy link
Contributor Author

kozuch commented Jul 6, 2017

I got another hint on IRC to update boost library from 1.54 to newer. Issues #35 and #37 seem to deal with this solving it with boost update to 1.62 and 1.63.

@kozuch
Copy link
Contributor Author

kozuch commented Jul 6, 2017

@royshil

I created a PR for the missing CMAKE_ preffixes: #41

However I do not know what minimum version of boost you need so you maybe want to add that yourself? The issues I linked above tested 1.62 to be working. I have not tested my upgraded boost yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants