我已经用vcpkg安装了点云库。我使用了命令行“vcpkg install pcl:x64-windows”,并与PCL一起安装了所有其他库。之后,我使用“。\ vcpkg \ vcpkg集成安装”使所有库直接在我的Visual Studio 2019项目中工作。实际上,该命令之后的我的项目(在https://pcl.readthedocs.io/projects/tutorials/en/latest/writing_pcd.html#writing-pcd处包含示例演示代码)正确地包含了两个头文件,并且没有显示任何问题。
但是,在运行代码后,我遇到了一堆与Boost库相关的错误,例如:
Error C2116 'boost::interprocess::winapi::GetFileSizeEx': function parameter lists do not match between declarations RegistrationAlgorithm C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\fileapi.h
Error C2733 'CreateSemaphoreA': you cannot overload a function with 'C' linkage RegistrationAlgorithm C:\vcpkg\vcpkg\installed\x64-windows\include\boost\interprocess\detail\win32_api.hpp
Error C4996 '_open': This function or variable may be unsafe. Consider using _sopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. RegistrationAlgorithm C:\vcpkg\vcpkg\installed\x64-windows\include\pcl\io\low_level_io.h
在这里问了相同的确切问题(相同的示例代码,相同的错误):point cloud library not working in VS 2019 but does work in VS 2017但是,他设法通过从VS2019生成工具(v142)切换到Visual Studio 2017生成工具(v141)使其工作。我下载了v141并进行了切换,但仍然遇到相同的错误。
有什么建议吗?
我尝试通过CMake运行代码,但是通过该过程,我遇到了更多错误。
最佳答案
这是Boost进程与MSVC 2019之间的兼容性问题。
根据Microsoft的说明,您可以在MSVC 2019中使用not-yet-documented兼容性开关来防止与外部extern“C”函数的重新声明有关的C2116
和C2733
错误。此选项是/Zc:externC-
这就留下了一些与使用不安全的CRT功能有关的C4996
错误。
根据错误消息,可以通过在包含头文件之前编写#define _CRT_SECURE_NO_WARNINGS
来抑制这些错误。
有了这些,示例代码就可以很好地构建了。
编辑:要添加该选项,请遵循此菜单/对话框路径-
关于c++ - 点云库不适用于Visual Studio 2019,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63266535/