我是PCL(点云库)的新手,我试图在Visual Studio 2019的网站上构建一个简单的点云可视化代码。当我尝试构建它时,它会在 PCL 文件夹中找到的头文件上出现错误。
我下载了PCL 1.6,其中包含第三方头文件。我检查了是否正确包含了构建代码所需的必要目录,没有遗漏任何东西。我不确定如何处理这些错误,因为它们是由 PCL 库中包含的头文件引起的。任何帮助将不胜感激。
附言很抱歉代码很长,错误消息很长。这是我第一次在这里发布问题。
以下是我在PCl网站上找到的简单点云可视化代码:
#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;
}
下面是导致错误的 PCL 文件夹中的头文件:
#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
以下是我在构建代码时不断收到的错误消息(由于我的帖子超过了字符数,我没有包含几行错误):
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 FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C2039: 'type': is not a member of '`global namespace''
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C2238: unexpected token(s) preceding ';'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C2976: 'Eigen::Eigen::internal::traits': too few template arguments
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C2039: 'StorageKind': is not a member of 'Eigen::Eigen::internal::traits'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C3646: 'StorageKind': unknown override specifier
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C2039: 'Index': is not a member of 'Eigen::Eigen::internal::traits'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C3646: 'Index': unknown override specifier
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(68,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(75,1): error C2144: syntax error: 'Eigen::Eigen::VectorBlock<VectorType,Size>' should be preceded by ';'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(74,5): error C7525: inline variables require at least '/std:c++17'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(75,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(86,1): error C2144: syntax error: 'Eigen::Eigen::VectorBlock<VectorType,Size>' should be preceded by ';'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(85,5): error C7525: inline variables require at least '/std:c++17'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(86,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreTranspose.h(76,5): error C2976: 'Eigen::Eigen::internal::traits': too few template arguments
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreTranspose.h(95): message : see reference to class template instantiation 'Eigen::Transpose<Derived>' being compiled
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreTranspose.h(76,5): error C2039: 'Scalar': is not a member of 'Eigen::Eigen::internal::traits'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(18): message : see declaration of 'Eigen::Eigen::internal::traits'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreTranspose.h(76,1): error C3646: 'Scalar': unknown override specifier
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreTranspose.h(76,1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreTranspose.h(76,1): error C2039: 'NumTraits': is not a member of 'Eigen::Eigen'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreVectorBlock.h(14): message : see declaration of 'Eigen::Eigen'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreTranspose.h(76,1): error C2059: syntax error: '<'
1>C:Program FilesPCL 1.6.03rdPartyEigenincludeEigensrcCoreDiagonal.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 ==========
更新:我已经下载了PCL 1.9.1并将其目录包含在我的项目中。我还下载了 Boost 1.70.0 以修复positioning.hpp
的错误。我现在的问题是 low_level_io.h 的错误。以下是我在构建项目时遇到的错误:
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 FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(60,16): error C2039: '_open': is not a member of '`global namespace''
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(60,21): error C3861: '_open': identifier not found
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(70,16): error C2039: '_open': is not a member of '`global namespace''
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(70,21): error C3861: '_open': identifier not found
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(80,16): error C2039: '_close': is not a member of '`global namespace''
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(80,22): error C3861: '_close': identifier not found
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(90,16): error C2039: '_lseek': is not a member of '`global namespace''
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(90,22): error C3861: '_lseek': identifier not found
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(100,16): error C2039: '_read': is not a member of '`global namespace''
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(100,21): error C3861: '_read': identifier not found
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(110,16): error C2039: '_write': is not a member of '`global namespace''
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(110,22): error C3861: '_write': identifier not found
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_level_io.h(120,16): error C2039: '_chsize': is not a member of '`global namespace''
1>C:Program FilesPCL 1.9.1includepcl-1.9pcliolow_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 ==========
有谁知道如何解决这个问题?任何帮助将不胜感激。
为了方便起见,我建议您下载多合一的exe文件并安装它,然后创建一个控制台c ++项目,手动添加包含和lib文件。
我通过使用CMake和PCL 1.9.1成功地构建了该程序。显然,使用 CMake 更容易,因为它会自动添加必要的包含和库目录来构建程序。