pcl::VoxelGrid How to get number of points in each voxel grid? - c++

I understand that pcl::VoxelGrid<PointT> can be used to downsample a PointCloud. In my use case, I want to get the number of points within each voxel grid. From PCL docs I found the leaf struct allows me to get the number of points in one voxel by calling getPointCount(). And pcl::VoxelGridCovariance allows me to get a leaf by calling getLeaf(). But I don't know how to apply all of these to a point cloud. I tried to initialize a pcl::VoxelGridCovariance<PointT> by pcl::VoxelGridCovariance<pcl::PCLPointCloud2> grid; but got the error as below. Could anyone know what's the problem here? Or is there any other way to get the number of points in each voxel? Any advice is appreciated!
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h: In instantiation of ‘struct pcl::traits::fieldList<pcl::PCLPointCloud2>’:
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:79:70: required from ‘class pcl::VoxelGridCovariance<pcl::PCLPointCloud2>’
/home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:549:60: required from here
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h:198:8: error: invalid use of incomplete type ‘struct pcl::traits::fieldList<pcl::PCLPointCloud2>’
struct fieldList /** \cond NO_WARN_RECURSIVE */ : fieldList<typename POD<PointT>::type> /** \endcond */
^~~~~~~~~
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h:198:8: note: declaration of ‘struct pcl::traits::fieldList<pcl::PCLPointCloud2>’
In file included from /usr/local/include/pcl-1.11/pcl/point_struct_traits.h:42:0,
from /usr/local/include/pcl-1.11/pcl/type_traits.h:40,
from /usr/local/include/pcl-1.11/pcl/memory.h:46,
from /usr/local/include/pcl-1.11/pcl/io/pcd_io.h:42,
from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:8:
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h:204:3: error: no matching function for call to ‘assertion_failed<false>(mpl_::failed************ (pcl::traits::fieldList<pcl::PCLPointCloud2>::POINT_TYPE_NOT_PROPERLY_REGISTERED::************)(pcl::PCLPointCloud2&))’
BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
^
/usr/include/boost/mpl/assert.hpp:83:5: note: candidate: template<bool C> int mpl_::assertion_failed(typename mpl_::assert<C>::type)
int assertion_failed( typename assert<C>::type );
^~~~~~~~~~~~~~~~
/usr/include/boost/mpl/assert.hpp:83:5: note: template argument deduction/substitution failed:
/usr/local/include/pcl-1.11/pcl/point_struct_traits.h:204:3: note: cannot convert ‘pcl::traits::fieldList<pcl::PCLPointCloud2>::POINT_TYPE_NOT_PROPERLY_REGISTERED205::assert_arg()’ (type ‘mpl_::failed************ (pcl::traits::fieldList<pcl::PCLPointCloud2>::POINT_TYPE_NOT_PROPERLY_REGISTERED::************)(pcl::PCLPointCloud2&)’) to type ‘mpl_::assert<false>::type {aka mpl_::assert<false>}’
BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
^
In file included from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:40:0:
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h: In instantiation of ‘class pcl::VoxelGridCovariance<pcl::PCLPointCloud2>’:
/home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:549:60: required from here
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:79:70: error: no type named ‘type’ in ‘struct pcl::traits::fieldList<pcl::PCLPointCloud2>’
using FieldList = typename pcl::traits::fieldList<PointT>::type;
^
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:80:61: error: no type named ‘PointCloud’ in ‘class pcl::Filter<pcl::PCLPointCloud2>’
using PointCloud = typename Filter<PointT>::PointCloud;
^
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:56:9: error: ‘std::__cxx11::string pcl::Filter<pcl::PCLPointCloud2>::filter_name_’ is protected within this context
class VoxelGridCovariance : public VoxelGrid<PointT>
^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/pcl-1.11/pcl/filters/filter_indices.h:42:0,
from /usr/local/include/pcl-1.11/pcl/filters/extract_indices.h:42,
from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:13:
/usr/local/include/pcl-1.11/pcl/filters/filter.h:240:19: note: declared protected here
std::string filter_name_;
^~~~~~~~~~~~
In file included from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:40:0:
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:56:9: error: ‘const string& pcl::Filter<pcl::PCLPointCloud2>::getClassName() const’ is protected within this context
class VoxelGridCovariance : public VoxelGrid<PointT>
^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/pcl-1.11/pcl/filters/filter_indices.h:42:0,
from /usr/local/include/pcl-1.11/pcl/filters/extract_indices.h:42,
from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:13:
/usr/local/include/pcl-1.11/pcl/filters/filter.h:253:7: note: declared protected here
getClassName () const
^~~~~~~~~~~~
In file included from /home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:40:0:
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h: In instantiation of ‘pcl::VoxelGridCovariance<PointT>::VoxelGridCovariance() [with PointT = pcl::PCLPointCloud2]’:
/home/linux/Documents/waymo_onTheGo/cart_boundary.cpp:549:60: required from here
/usr/local/include/pcl-1.11/pcl/filters/voxel_grid_covariance.h:205:18: error: using invalid field ‘pcl::VoxelGridCovariance<PointT>::voxel_centroids_’
kdtree_ ()
^

To just access the number of points, use OctreePointCloudDensity
To also access the points inside each voxel, use OctreePointCloudPointVector

Related

Is this a bug in the boost library

I'm compiling a project with autotools and am using g++ in version gcc version 5.3.1 and boost version 1_63. After aclocal, autoconf, autoheader, automake --add-missing, I ran configure with some options, which succedded and build make a Makefile. Running make fails and gives me the error (excerpt):
In file included from /usr/local/include/boost/ratio/ratio.hpp:46:0,
from /usr/local/include/boost/chrono/duration.hpp:41,
from /usr/local/include/boost/chrono/time_point.hpp:33,
from /usr/local/include/boost/thread/lock_types.hpp:22,
from /usr/local/include/boost/thread/pthread/mutex.hpp:16,
from /usr/local/include/boost/thread/mutex.hpp:16,
from src/cosupport-initializer/cpp/BasicInitializer.cpp:39:
/usr/local/include/boost/integer_traits.hpp:83:46: error: 'CHAR_MIN' was not declared in this scope
public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:83:56: error: 'CHAR_MAX' was not declared in this scope
public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:83:64: error: template argument 2 is invalid
public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:83:64: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:89:53: error: 'SCHAR_MIN' was not declared in this scope
public detail::integer_traits_base<signed char, SCHAR_MIN, SCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:89:64: error: 'SCHAR_MAX' was not declared in this scope
public detail::integer_traits_base<signed char, SCHAR_MIN, SCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:89:73: error: template argument 2 is invalid
public detail::integer_traits_base<signed char, SCHAR_MIN, SCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:89:73: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:95:58: error: 'UCHAR_MAX' was not declared in this scope
public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:95:67: error: template argument 3 is invalid
public detail::integer_traits_base<unsigned char, 0, UCHAR_MAX>
^
/usr/local/include/boost/integer_traits.hpp:131:47: error: 'SHRT_MIN' was not declared in this scope
public detail::integer_traits_base<short, SHRT_MIN, SHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:131:57: error: 'SHRT_MAX' was not declared in this scope
public detail::integer_traits_base<short, SHRT_MIN, SHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:131:65: error: template argument 2 is invalid
public detail::integer_traits_base<short, SHRT_MIN, SHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:131:65: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:137:59: error: 'USHRT_MAX' was not declared in this scope
public detail::integer_traits_base<unsigned short, 0, USHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:137:68: error: template argument 3 is invalid
public detail::integer_traits_base<unsigned short, 0, USHRT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:143:45: error: 'INT_MIN' was not declared in this scope
public detail::integer_traits_base<int, INT_MIN, INT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:143:54: error: 'INT_MAX' was not declared in this scope
public detail::integer_traits_base<int, INT_MIN, INT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:143:61: error: template argument 2 is invalid
public detail::integer_traits_base<int, INT_MIN, INT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:143:61: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:149:57: error: 'UINT_MAX' was not declared in this scope
public detail::integer_traits_base<unsigned int, 0, UINT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:149:65: error: template argument 3 is invalid
public detail::integer_traits_base<unsigned int, 0, UINT_MAX>
^
/usr/local/include/boost/integer_traits.hpp:155:46: error: 'LONG_MIN' was not declared in this scope
public detail::integer_traits_base<long, LONG_MIN, LONG_MAX>
^
/usr/local/include/boost/integer_traits.hpp:155:56: error: 'LONG_MAX' was not declared in this scope
public detail::integer_traits_base<long, LONG_MIN, LONG_MAX>
^
/usr/local/include/boost/integer_traits.hpp:155:64: error: template argument 2 is invalid
public detail::integer_traits_base<long, LONG_MIN, LONG_MAX>
^
/usr/local/include/boost/integer_traits.hpp:155:64: error: template argument 3 is invalid
/usr/local/include/boost/integer_traits.hpp:161:58: error: 'ULONG_MAX' was not declared in this scope
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
^
/usr/local/include/boost/integer_traits.hpp:161:67: error: template argument 3 is invalid
public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
This means e.g. that in /usr/local/include/boost/integer_traits.hpp on line 83, the constructor initialization fails:
template<>
class integer_traits<char>
: public std::numeric_limits<char>,
public detail::integer_traits_base<char, CHAR_MIN, CHAR_MAX>
{ };
This means in the file /usr/local/include/boost/integer_traits.hpp and headers included in it, there's no definition of CHAR_MIN. So this is a bug in boost? Or what am I missing here?
UPDATE
The relevant code excerpts. Before the move:
#include <CoSupport/compatibility-glue/nullptr.h>
#include <CoSupport/Initializer/BasicInitializer.hpp>
#include <boost/thread/mutex.hpp>
#include <cassert>
namespace CoSupport {
...
}
After the move:
#include <boost/thread/mutex.hpp>
#include <CoSupport/compatibility-glue/nullptr.h>
#include <CoSupport/Initializer/BasicInitializer.hpp>
#include <cassert>
namespace CoSupport {
...
}
This means in the file /usr/local/include/boost/integer_traits.hpp and headers included in it, there's no definition of CHAR_MIN
Which is as it should be - CHAR_MIN is defined in <climits>.
So this is a bug in boost? Or what am I missing here?
With 99% certainty, this is not a bug in boost. You probably have some include files of your own, in your project's include directories, masking climits or limits.h, or possibly another file which interger_traits.hpp includes and itself includes climits or limits.h.

How to compile a program from .cpp files and a makefile

I recently downloaded a program. A patient specific survival prediction CLI, http://pssp.srv.ualberta.ca/
The readme included states:
"1 Compilation
The code should compile on Linux without any modification. To compile, just type ’make’. There should
be 2 executables after compilation, mtlr train and mtlr test."
I download an extracted the folder to my location, when I go into the directory and type make I get:
x#x-laptop:/pssp_source$ make
g++ -c -O3 DenseVector.cpp -o DenseVector.o
In file included from DenseVector.cpp:1:0:
DenseVector.h:9:2: error: ‘size_t’ does not name a type
size_t m_dim;
^
DenseVector.h:18:21: error: expected ‘)’ before ‘n’
DenseVector(size_t n);
^
DenseVector.h:26:33: error: ‘size_t’ does not name a type
double const& operator[](const size_t i) const
^
DenseVector.h:26:40: error: ISO C++ forbids declaration of ‘i’ with no type [-fpermissive]
double const& operator[](const size_t i) const
^
DenseVector.h:31:27: error: ‘size_t’ does not name a type
double& operator[](const size_t i)
^
DenseVector.h:31:34: error: ISO C++ forbids declaration of ‘i’ with no type [-fpermissive]
double& operator[](const size_t i)
^
DenseVector.h:38:2: error: ‘size_t’ does not name a type
size_t dim() const
^
DenseVector.h: In member function ‘void DenseVector::push_back(double)’:
DenseVector.h:23:3: error: ‘m_dim’ was not declared in this scope
m_dim++;
^
DenseVector.cpp: At global scope:
DenseVector.cpp:6:1: error: prototype for ‘DenseVector::DenseVector(size_t)’ does not match any in class ‘DenseVector’
DenseVector::DenseVector(size_t n): m_dim(n)
^
In file included from DenseVector.cpp:1:0:
DenseVector.h:5:7: error: candidates are: DenseVector::DenseVector(const DenseVector&)
class DenseVector
^
DenseVector.h:12:2: error: DenseVector::DenseVector()
DenseVector(void);
^
DenseVector.cpp: In constructor ‘DenseVector::DenseVector()’:
DenseVector.cpp:16:2: error: class ‘DenseVector’ does not have any field named ‘m_dim’
:m_dim(0)
^
DenseVector.cpp: In member function ‘void DenseVector::clear()’:
DenseVector.cpp:27:22: error: ‘m_dim’ was not declared in this scope
for (size_t i=0; i<m_dim; i++)
^
In file included from /usr/include/c++/4.8/cassert:43:0,
from DenseVector.cpp:3:
DenseVector.cpp: In function ‘double sprod_nn(const DenseVector&, const DenseVector&)’:
DenseVector.cpp:37:11: error: ‘const class DenseVector’ has no member named ‘dim’
assert(a.dim() == b.dim());
^
DenseVector.cpp:37:22: error: ‘const class DenseVector’ has no member named ‘dim’
assert(a.dim() == b.dim());
^
DenseVector.cpp:38:15: error: ‘const class DenseVector’ has no member named ‘dim’
size_t n = a.dim();
^
In file included from /usr/include/c++/4.8/cassert:43:0,
from DenseVector.cpp:3:
DenseVector.cpp: In function ‘void multadd_nn(DenseVector&, const DenseVector&, double)’:
DenseVector.cpp:49:11: error: ‘class DenseVector’ has no member named ‘dim’
assert(w.dim()==a.dim());
^
DenseVector.cpp:49:20: error: ‘const class DenseVector’ has no member named ‘dim’
assert(w.dim()==a.dim());
^
DenseVector.cpp:50:15: error: ‘class DenseVector’ has no member named ‘dim’
size_t n = w.dim();
^
DenseVector.cpp: In function ‘void smult_n(DenseVector&, double)’:
DenseVector.cpp:62:15: error: ‘class DenseVector’ has no member named ‘dim’
size_t n = w.dim();
^
make: *** [DenseVector.o] Error 1
The contents of the folder look like:
x#x-laptop:/pssp_source$ ls
common.cpp data_type_api.h DenseVector.h Main.cpp Makefile Sparm.cpp Sparm.o SparseVector.h test_model.mltr Util.h
common.h DenseVector.cpp example_data Main.o readme.pdf Sparm.h SparseVector.cpp Test.cpp test_model.mlty
I looked up the basic packages needed for compiling c++ code, as well as basics on how to run it and none have gotten me past this issue. It looks as if it has a problem with size_t not having a type.
The start of DenseVector.cpp is :
#include "DenseVector.h"
#include <cassert>
#include <iostream>
DenseVector::DenseVector(size_t n): m_dim(n)
{
m_dvector.reserve(n);
for (size_t i=0; i<n; i++)
{
m_dvector.push_back(0);
}
}
I have never compiled code like this before, so I am probably missing something obvious. If its needed I am running ubuntu 14.04, g++ version is
4.8.4.
Thanks
It sounds like the README lied. Probably it happened to work with a different version of the standard library.
Try adding
#include <stddef.h>
near the top of DenseVector.h.
Open the file DenseVector.h in the root directory of the program and modify it, inserting
#pragma once
#include <vector>
#include <cstddef> // <--- Add this line to the file
class DenseVector
{
protected:
// ...
Save it and try again!
I don't think you are using the correct version of C; I think you need C11. Instead of using the -03 flag, use -11 or -std=c11. Then recompile it.

Boost 1.5.8 issue

I've got lots of bugs in my old compilation machine so I decided to create a new one.
Boh project doesn't have any issue about compiling in BOOST 1.55, but in 1.5.7 or highter, only one project can compile. (Before, both are using boost 1.5.7 without problem)
Here's the bug when i'm using 1.5.8 (at char_skill.cpp)
http://i.stack.imgur.com/sh8vO.png
Text mode :
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:193:24: note: template argument deduction/substitution failed:
In file included from /usr/src/blabla/Extern/include/boost/functional/hash/hash.hpp:558:0,
from /usr/src/blabla/Extern/include/boost/functional/hash.hpp:6,
from /usr/src/blabla/Extern/include/boost/unordered/unordered_map.hpp:21,
from /usr/src/blabla/Extern/include/boost/unordered_map.hpp:17,
from char.h:4,
from char_skill.cpp:7:
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:262:34: note: 'const VID' is not derived from 'const std::shared_ptr<_Tp1>'
return hash_value(val);
^
In file included from /usr/src/blabla/Extern/include/boost/functional/hash/hash.hpp:558:0,
from /usr/src/blabla/Extern/include/boost/functional/hash.hpp:6,
from /usr/src/blabla/Extern/include/boost/unordered/unordered_map.hpp:21,
from /usr/src/blabla/Extern/include/boost/unordered_map.hpp:17,
from char.h:4,
from char_skill.cpp:7:
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:198:24: note: template<class T, class Deleter> std::size_t boost::hash_value(const std::unique_ptr<_Tp, _Dp>&)
inline std::size_t hash_value(std::unique_ptr<T, Deleter> const& x) {
^
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:198:24: note: template argument deduction/substitution failed:
In file included from /usr/src/blabla/Extern/include/boost/functional/hash/hash.hpp:558:0,
from /usr/src/blabla/Extern/include/boost/functional/hash.hpp:6,
from /usr/src/blabla/Extern/include/boost/unordered/unordered_map.hpp:21,
from /usr/src/blabla/Extern/include/boost/unordered_map.hpp:17,
from char.h:4,
from char_skill.cpp:7:
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:262:34: note: 'const VID' is not derived from 'const std::unique_ptr<_Tp, _Dp>'
return hash_value(val);
^
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp: In member function 'std::size_t boost::hash<T>::operator()(const T&) const [with T = VID; std::size_t = unsigned int]':
/usr/src/blabla/Extern/include/boost/functional/hash/extensions.hpp:263:9: warning: control reaches end of non-void function [-Wreturn-type]
}
^
gmake: *** [OBJDIR/char_skill.o] Error 1
I don't know why I have this problem :x
PS : If anyone know how to install boost-all (1.5.7 or +) using freebsd ^^
Have a nice day :)

map in c++ causes error

I have header file. I want a map object added to one of the structures. So I included
#include<map>
and compiled the program (note I did not use map object I just included it) and I got the following error
/usr/include/c++/4.7/bits/stl_map.h:115:28: error: macro "value_compare" requires 2 arguments, but only 1 given
/usr/include/c++/4.7/bits/stl_map.h:733:45: error: macro "value_compare" requires 2 arguments, but only 1 given
In file included from /usr/include/c++/4.7/map:62:0,
from ../optimizer_types.h:16,
from ../main.cpp:20:
/usr/include/c++/4.7/bits/stl_multimap.h:115:28: error: macro "value_compare" requires 2 arguments, but only 1 given
/usr/include/c++/4.7/bits/stl_multimap.h:656:45: error: macro "value_compare" requires 2 arguments, but only 1 given
In file included from /usr/include/c++/4.7/map:61:0,
from ../optimizer_types.h:16,
from ../main.cpp:20:
/usr/include/c++/4.7/bits/stl_map.h:113:11: error: invalid use of non-static data member 'std::map<_Key, _Tp, _Compare, _Alloc>::value_compare::comp'
/usr/include/c++/4.7/bits/stl_map.h:116:4: error: from this location
/usr/include/c++/4.7/bits/stl_map.h:116:9: error: '__c' was not declared in this scope
/usr/include/c++/4.7/bits/stl_map.h:116:12: error: a function call cannot appear in a constant-expression
/usr/include/c++/4.7/bits/stl_map.h:116:12: error: expected ';' at end of member declaration
/usr/include/c++/4.7/bits/stl_map.h:116:14: error: expected unqualified-id before '{' token
/usr/include/c++/4.7/bits/stl_map.h: In member function 'std::map<_Key, _Tp, _Compare, _Alloc>::value_compare std::map<_Key, _Tp, _Compare, _Alloc>::value_comp() const':
/usr/include/c++/4.7/bits/stl_map.h:733:46: error: expected primary-expression before ';' token
In file included from /usr/include/c++/4.7/map:62:0,
from ../optimizer_types.h:16,
from ../main.cpp:20:
/usr/include/c++/4.7/bits/stl_multimap.h: At global scope:
/usr/include/c++/4.7/bits/stl_multimap.h:113:11: error: invalid use of non-static data member 'std::multimap<_Key, _Tp, _Compare, _Alloc>::value_compare::comp'
/usr/include/c++/4.7/bits/stl_multimap.h:116:4: error: from this location
/usr/include/c++/4.7/bits/stl_multimap.h:116:9: error: '__c' was not declared in this scope
/usr/include/c++/4.7/bits/stl_multimap.h:116:12: error: a function call cannot appear in a constant-expression
/usr/include/c++/4.7/bits/stl_multimap.h:116:12: error: expected ';' at end of member declaration
/usr/include/c++/4.7/bits/stl_multimap.h:116:14: error: expected unqualified-id before '{' token
/usr/include/c++/4.7/bits/stl_multimap.h: In member function 'std::multimap<_Key, _Tp, _Compare, _Alloc>::value_compare std::multimap<_Key, _Tp, _Compare, _Alloc>::value_comp() const':
/usr/include/c++/4.7/bits/stl_multimap.h:656:46: error: expected primary-expression before ';' token
As an experiment I moved the include to a cpp file and it was compiling properly.
What could be the reason
Try this:
#ifdef value_compare
#undefine value_compare // std::map header doesn't like this
#endif
#include <map>
It's not very flexible (or pretty) but it should get you through this :(
Edit: Either way, the problem is not including map, but the earlier include/code that defined value_compare macro. Is it a C header? (I doubt a C++ would define a macro with this name, as value_compare is an important part of the C++ standard library).

Compiling C++ Thrift code to interface Cassandra results in following errors. What are we missing here?

$ g++ -lthrift -Wall thriftfs.cpp cassandra_constants.cpp Cassandra.cpp cassandra_types.cpp -o thriftfs -I/usr/local/include/thrift -L/usr/local/lib
In file included from /usr/local/include/thrift/protocol/TProtocol.h:23:0,
from /usr/local/include/thrift/TProcessor.h:24,
from Cassandra.h:10,
from t`enter code here`hriftfs.cpp:4:
/usr/local/include/thrift/transport/TTransport.h:34:1: error: ‘uint32_t’ does not name a type
/usr/local/include/thrift/transport/TTransport.h:156:29: error: ISO C++ forbids declaration of ‘buf’ with no type [-fpermissive]
In file included from /usr/local/include/thrift/TProcessor.h:24:0,
from Cassandra.h:10,
from thriftfs.cpp:4:
/usr/local/include/thrift/protocol/TProtocol.h:184:1: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:10:0,
from thriftfs.cpp:4:
/usr/local/include/thrift/TProcessor.h:72:57: error: ‘uint32_t’ has not been declared
In file included from cassandra_types.h:11:0,
from Cassandra.h:11,
from thriftfs.cpp:4:
/usr/local/include/thrift/TApplicationException.h:94:3: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:85:16: error: ‘uint8_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:142:3: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:1478:16: error: ‘uint8_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:1812:3: error: ‘uint32_t’ does not name a type
In file included from thriftfs.cpp:4:0:
Cassandra.h:217:3: error: ‘uint32_t’ does not name a type
Cassandra.h:4857:35: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4857:62: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4859:71: error: cannot declare pointer to ‘void’ member
Cassandra.h:4859:145: error: template argument 2 is invalid
Cassandra.h:4859:145: error: template argument 4 is invalid
Cassandra.h:4860:45: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4860:72: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4935:42: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:42: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:42: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:42: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:77: error: template argument 1 is invalid
Cassandra.h:4935:105: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:105: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:105: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:105: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:140: error: template argument 1 is invalid
Cassandra.h: In constructor ‘org::apache::cassandra::CassandraProcessor::CassandraProcessor(boost::shared_ptr)’:
Cassandra.h:4898:49: error: assignment of read-only location ‘"login"[((org::apache::cassandra::CassandraProcessor*)this)->org::apache::cassandra::CassandraProcessor::processMap_]’
Cassandra.h:4898:49: error: cannot convert ‘void (org::apache::cassandra::CassandraProcessor::*)(int32_t, int) {aka void (org::apach
Add the following defines:
g++ -DHAVE_NETINET_IN_H -DHAVE_INTTYPES_H ...
Or add #include <stdint.h> before including Thrift.h in your code.
See the discussion at THRIFT-1326. The issue is suppposedly fixed in thrift 0.9.
It looks like your problem is a compiler issue.
It can't find the type "uint32_t"
There is another question on SO regarding this:
'uint32_t' identifier not found error
Quoted from user templatetypedef
This type is defined in the C header which is not currently
a part of the C++ standard. According to the Wikipedia page on the
header, it hasn't shipped with Visual Studio until VS2010.
In the meantime, you could probably fake up your own version of the
header by adding typedefs that map Microsoft's custom integer types to
the types expected by C. For example:
typedef __int32 int32_t; typedef unsigned __int32 uint32_t; /* ...
etc. ... */ Hope this helps!