Hello. I have a problem with using the PCL library in MFC environment.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Hello. I have a problem with using the PCL library in MFC environment.

swennoir
This post has NOT been accepted by the mailing list yet.
Hi. I have downloaded "PCL 1.6.0 All-In-One Installer" for Windows VS2010(x64) and installed successfully. Also, I have compiled the sample code successfully in Win32 console  application(C/C++) environment. The code is located below.

////////////////////////////////////////////////////////////////////////////////////

   #include <pcl/io/pcd_io.h>
   #include <pcl/point_types.h>
   #include <pcl/visualization/cloud_viewer.h>

        // PCL Cloud file generating code
       
        pcl::PointCloud<pcl::PointXYZ> cloud;

        // Fill in the cloud data
        cloud.width = 100;
        cloud.height = 1;
        cloud.is_dense = false;
        cloud.points.resize(cloud.width * cloud.height);

        for (size_t i = 0; i<cloud.points.size(); ++i)
        {
                cloud.points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
                cloud.points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
                cloud.points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
        }

        pcl::io::savePCDFileASCII("test_pcd.pcd", cloud);

        ////////////////////////////////////
        // Load the file
        pcl::PointCloud<pcl::PointXYZ>::Ptr pcloud (new pcl::PointCloud<pcl::PointXYZ>);

        if (pcl::io::loadPCDFile<pcl::PointXYZ>("test_pcd.pcd", *pcloud) == -1)
        {
                PCL_ERROR("Couldn't read file.\n");
                return(-1);
        }

        // Viewer
        pcl::visualization::CloudViewer viewer("PCL Viewer");
        viewer.showCloud(pcloud);
        while (!viewer.wasStopped())
        {

        }
////////////////////////////////////////////////////////////////////////////////////

However, the errors occurred when I compile in dialog-based MFC environment with the same code. The representative errors were

 pcl/io/pcd_io.h(328): error C2589: '(' : illegal token on right side of '::'
 pcl/io/pcd_io.h(341): error C2589: '(' : illegal token on right side of '::'
 pcl/correspondence.h(70): error C2589: '(' : illegal token on right side of '::'
 pcl/correspondence.h(94): error C2065: 'Correspondences' : undeclared identifier
 pcl/correspondence.h(120): fatal error C1903: unable to recover from  previous error(s); stopping compilation.

These errors did not show up when I compile the code in Win32 console environment. Therefore, I added "#undef   min, #undef   max" before the header(pcl/io/pcd_io.h), then the errors disappeared even there are a lot of warnings.

Nonetheless, another errors occurred. The location of the errors is the part of loading PCD file.

1.Location of error: "pcl::PointCloud<pcl::PointXYZ>::Ptr pcloud (new pcl::PointCloud<pcl::PointXYZ>);"
Error message: "Error: no instance of overloaded "pcl::PointCloud<PointT>::operator new [with PointT=pcl::PointXYZ]" matches the argument list"

2.Location of error: "return(-1);"
Error message: "Error: return value type does not match the function type"


Please help me to solve this problem.