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

[compile error] "VC++, C2061 syntax error in pcl/io/low_level_io.h(58,17) regarding the identifier 'SSIZE_T'." #5852

Open
koomiy opened this issue Oct 22, 2023 · 3 comments
Labels
kind: compile error Type of issue status: triage Labels incomplete

Comments

@koomiy
Copy link

koomiy commented Oct 22, 2023

Error Details
Hello.
When compiling pcl with VC++, I get a C2061 syntax error in pcl/io/low_level_io.h(58,17) regarding the identifier 'SSIZE_T'.

Here is the error code.
C:\devel\vcpkg\packages\pcl_x64-windows\include\pcl/io/low_level_io.h(58,17): error C2061: 構文エラー: 識別子 'SSIZE_T'

To Reproduce

  • OS: [Windows 11]
  • Compiler: [CMake]
  • PCL Version [1.13.1]
  • PCL Type: [Installed with VCPKG]

My development environment is Windows 11, Visual Studio Community 2019.
And I use Cmake for compilation.

First of all, vcpkg was installed in the C:/devel directory and pcl was installed via vcpkg.
As a result, pcl was installed in C:/devel/vcpkg/packages/pcl_x64-windows.

I'm trying to install pcl as an external library in choreonoid's sample package vnoid.
I have written choreonoid/ext/vnoid/src/CmakeList.txt as follows:
=================choreonoid/ext/vnoid/src/CmakeList.txt==============

set(PCL_DIR "C:/devel/vcpkg/packages/pcl_x64-windows/share/pcl")

find_package(PCL 1.13.1 REQUIRED COMPONENTS common io)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

set(VNOID_HEADERS
    "fksolver.h"
    "iksolver.h"
    "filter.h"
    "footstep.h"
    "footstep_planner.h"
    "ground_estimator.h"
    "robot.h"
    "rollpitchyaw.h"
    "stabilizer.h"
    "stepping_controller.h"
    "visualizer.h"
    "debug.h"
    "mycamera.h"
	)
set(VNOID_SOURCES
    "fksolver.cpp"
    "iksolver.cpp"
    "filter.cpp"
    "footstep.cpp"
    "footstep_planner.cpp"
    "ground_estimator.cpp"
    "robot.cpp"
    "rollpitchyaw.cpp"
    "stabilizer.cpp"
    "stepping_controller.cpp"
    "visualizer.cpp"
    "debug.cpp"
    "mycamera.cpp"
	)

choreonoid_add_library(vnoid_lib STATIC ${VNOID_HEADERS} ${VNOID_SOURCES})

target_link_libraries(vnoid_lib CnoidBody ${PCL_LIBRARIES})

choreonoid_add_body_handler(SwingBridgeHandler SwingBridgeHandler.cpp)

=========================================================

Then, I cross-compiled using the following code:

cmake -B C:\devel\choreonoid\build -DCMAKE_TOOLCHAIN_FILE=D:\devel\vcpkg\scripts\buildsystems\vcpkg.cmake

With that compilation, configure and generate succeeded.

Next, I wrote the following program to obtain a 3D point cloud and attempted to build it.
=================choreonoid/ext/vnoid/src/mycamera.cpp==============

#include "mycamera.h"

namespace cnoid {
namespace vnoid {

MyCamera::MyCamera() {
    timeStep = 1.0;
}

void MyCamera::Init(SimpleControllerIO* io) {
    // enable camera
    cameras << io->body()->devices();
    for (size_t i = 0; i < cameras.size(); ++i) {
        Device* camera = cameras[i];
        io->enableInput(camera);

        OPD("Device type: %s, ", camera->typeName());
        OPD("id: %s, ", camera->id());
        OPD("name: %s.\n", camera->name());
    }

    timeCounter = 0.0;
    timeStep = io->timeStep();
}

void MyCamera::TerrainAnalysis() {
    //// sample code of image saving
    /* for (size_t i = 0; i < cameras.size(); i++) {
        RangeCamera* camera = cameras[i];
        std::string filename = camera->name() + ".png";
        camera->constImage().save(filename);

        OPD("The image of %s", camera->name());
        OPD("has been saved to \"%s\".\n", filename);
    }*/

    //// here is the program of getting point cloud data
    // get cameras
    // when there are several cameras
    for (size_t i = 0; i < cameras.size(); i++) {
        RangeCamera* camera = cameras[i];
    }
    // only one camera
    RangeCamera* camera = cameras[0];

    // Get an image of the current scene
    const Image& RangeImage = camera->constImage();
    // Save an image of current scene
    RangeImage.save("pointcloud.png");
    // width and height of this image
    const int width = RangeImage.width();
    const int height = RangeImage.height();
    // get color data of this image
    const unsigned char* pixels = RangeImage.pixels();

    // point cloud variable declaration
    pcl::PointCloud<pcl::PointXYZRGB> cloud;
    // initialize point cloud
    cloud.width = width;
    cloud.height = height;
    cloud.is_dense = false;
    cloud.points.resize(cloud.width * cloud.height);

    // Stores values (coordinates, color) for each point in a point cloud
    std::size_t i = 0;
    for (const auto& e : camera->constPoints()) {
        // X, Y, Z
        cloud[i].x = e(0);
        cloud[i].y = e(1);
        cloud[i].z = e(2);

        // color(R, G, B)
        cloud[i].r = pixels[3 * i + 0];
        cloud[i].g = pixels[3 * i + 1];
        cloud[i].b = pixels[3 * i + 2];

        ++i;
    }
    
    // save the point cloud data
    pcl::io::savePCDFileBinaryCompressed("pointcloud.pcd", cloud);
    OPD("save pointcloud\n");

}

}  // namespace vnoid
}  // namespace cnoid

=========================================================
=================choreonoid/ext/vnoid/src/mycamera.h===============

#pragma once

#include <cnoid/SimpleController>
#include <cnoid/EigenTypes>
#include <cnoid/RangeCamera>

#include <iostream>

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

#include "debug.h"


namespace cnoid {
namespace vnoid {

class MyCamera : RangeCamera
{
public: 
    DeviceList<RangeCamera> cameras;
    double timeCounter;
    double timeStep;

public: 
	virtual void Init(SimpleControllerIO* io);
    virtual void TerrainAnalysis();

	MyCamera();

};

}  // namespace vnoid
}  // namespace cnoid

=========================================================
However, it could not be built correctly because of the error described at the beginning of this article.

I would appreciate any insight into this error.

@koomiy koomiy added kind: compile error Type of issue status: triage Labels incomplete labels Oct 22, 2023
@mvieth
Copy link
Member

mvieth commented Oct 22, 2023

That is strange. According to https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types#ssize_t , SSIZE_T should be available after including basetsd.h
Which compiler do you use to compile mycamera.cpp? Also Visual Studio 2019? You mentioned something about cross-compiling?

@koomiy
Copy link
Author

koomiy commented Oct 23, 2023

Yes this is strange.
I also use Visual Studio 2019 to compile mycamera.cpp.

Cross-compilation with Cmake was performed to remember dependencies between choreonoid and external source or/and header files (e.g. pcl). All choreonoid project (including mycamera.cpp) was compiled with Visual Studio 2019.

@mvieth
Copy link
Member

mvieth commented Oct 23, 2023

Maybe search your computer for basetsd.h and check whether SSIZE_T is defined in there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: compile error Type of issue status: triage Labels incomplete
Projects
None yet
Development

No branches or pull requests

2 participants