I'm new to PCL (point cloud library) and I was trying to build a simple point cloud visualization code I found on their website in Visual Studio 2019. When I tried to build it, it gives me errors on the header files found in the PCL folder.
I downloaded PCL 1.6 and there are 3rd party header files included. I checked if I correctly included the necessary directories needed to build the code, nothing was missing. I'm not sure how to approach the errors since they are caused by the header files included in the PCL library. Any help would be greatly appreciated.
P.S. I'm sorry for the long code and error message. This is my first time posting a problem here.
Below is the simple point cloud visualization code I found in the PCl website:
#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
int user_data;
void
viewerOneOff(pcl::visualization::PCLVisualizer& viewer)
{
viewer.setBackgroundColor(1.0, 0.5, 1.0);
pcl::PointXYZ o;
o.x = 1.0;
o.y = 0;
o.z = 0;
viewer.addSphere(o, 0.25, "sphere", 0);
std::cout << "i only run once" << std::endl;
}
void
viewerPsycho(pcl::visualization::PCLVisualizer& viewer)
{
static unsigned count = 0;
std::stringstream ss;
ss << "Once per viewer loop: " << count++;
viewer.removeShape("text", 0);
viewer.addText(ss.str(), 200, 300, "text", 0);
//FIXME: possible race condition here:
user_data++;
}
int
main()
{
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::io::loadPCDFile("my_point_cloud.pcd", *cloud);
pcl::visualization::CloudViewer viewer("Cloud Viewer");
//blocks until the cloud is actually rendered
viewer.showCloud(cloud);
//use the following functions to get access to the underlying more advanced/powerful
//PCLVisualizer
//This will only get called once
viewer.runOnVisualizationThreadOnce(viewerOneOff);
//This will get called once per visualization iteration
viewer.runOnVisualizationThread(viewerPsycho);
while (!viewer.wasStopped())
{
//you can also do cool processing here
//FIXME: Note that this is running in a separate thread from viewerPsycho
//and you should guard against race conditions yourself...
user_data++;
}
return 0;
}
Here is the Header file from the PCL folder that causes the error:
#ifndef EIGEN_VECTORBLOCK_H
#define EIGEN_VECTORBLOCK_H
namespace Eigen {
namespace internal {
template<typename VectorType, int Size>
struct traits<VectorBlock<VectorType, Size> >
: public traits<Block<VectorType,
traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
traits<VectorType>::Flags & RowMajorBit ? Size : 1> >
{
};
}
template<typename VectorType, int Size> class VectorBlock
: public Block<VectorType,
internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1>
{
typedef Block<VectorType,
internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base;
enum {
IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit)
};
public:
EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock)
using Base::operator=;
EIGEN_DEVICE_FUNC
inline VectorBlock(VectorType& vector, Index start, Index size)
: Base(vector,
IsColVector ? start : 0, IsColVector ? 0 : start,
IsColVector ? size : 1, IsColVector ? 1 : size)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
}
EIGEN_DEVICE_FUNC
inline VectorBlock(VectorType& vector, Index start)
: Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
}
};
} // end namespace Eigen
#endif // EIGEN_VECTORBLOCK_H
Below is the error message I keep getting when I build the code (I didn't include a few lines of error since my post exceeded the character count):
1>------ Build started: Project: PCL_trial, Configuration: Debug x64 ------
1>PCL_trial.cpp
1>Unknown compiler version - please run the configure tests and report the results
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2039: 'type': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2238: unexpected token(s) preceding ';'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2976: 'Eigen::Eigen::internal::traits': too few template arguments
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2039: 'StorageKind': is not a member of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C3646: 'StorageKind': unknown override specifier
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C2039: 'Index': is not a member of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C3646: 'Index': unknown override specifier
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(68,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(75,1): error C2144: syntax error: 'Eigen::Eigen::VectorBlock<VectorType,Size>' should be preceded by ';'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(74,5): error C7525: inline variables require at least '/std:c++17'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(75,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(86,1): error C2144: syntax error: 'Eigen::Eigen::VectorBlock<VectorType,Size>' should be preceded by ';'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(85,5): error C7525: inline variables require at least '/std:c++17'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(86,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,5): error C2976: 'Eigen::Eigen::internal::traits': too few template arguments
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(95): message : see reference to class template instantiation 'Eigen::Transpose<Derived>' being compiled
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,5): error C2039: 'Scalar': is not a member of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,1): error C3646: 'Scalar': unknown override specifier
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,1): error C2039: 'NumTraits': is not a member of 'Eigen::Eigen'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\VectorBlock.h(14): message : see declaration of 'Eigen::Eigen'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Transpose.h(76,1): error C2059: syntax error: '<'
1>C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include\Eigen\src\Core\Diagonal.h(83,1): error C1003: error count exceeds 100; stopping compilation
1>Done building project "PCL_trial.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
UPDATE: I have downloaded PCL 1.9.1 and included its directory to my project. I also downloaded Boost 1.70.0 to fix the error with positioning.hpp. My problem now is the error with low_level_io.h. Below is the error I'm getting when building the project:
1>PCL_trial.cpp
1>The use of BOOST_*_ENDIAN and BOOST_BYTE_ORDER is deprecated. Please include <boost/predef/other/endian.h> and use BOOST_ENDIAN_*_BYTE instead
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(60,16): error C2039: '_open': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(60,21): error C3861: '_open': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(70,16): error C2039: '_open': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(70,21): error C3861: '_open': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(80,16): error C2039: '_close': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(80,22): error C3861: '_close': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(90,16): error C2039: '_lseek': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(90,22): error C3861: '_lseek': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(100,16): error C2039: '_read': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(100,21): error C3861: '_read': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(110,16): error C2039: '_write': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(110,22): error C3861: '_write': identifier not found
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(120,16): error C2039: '_chsize': is not a member of '`global namespace''
1>C:\Program Files\PCL 1.9.1\include\pcl-1.9\pcl\io\low_level_io.h(120,23): error C3861: '_chsize': identifier not found
1>Done building project "PCL_trial.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Does anyone know how to fix this? Any help would be appreciated.
CMakeLists.txtfile look like? - kanstar