Osz*_*kar 2 c++ compiler-construction visual-studio-2010 point-clouds
我正在尝试使用带有多个文件的Point Cloud Library和OpenCV来实现测试项目.当我尝试编译时,我收到"已定义的错误"消息.可能我做了一些愚蠢的事情,由于某些原因无法实现 - 我尝试了一些在这里找到的解决方案,在我的案例中似乎没有任何帮助.
是)我有的:
一个libs.h文件,我在其中加载lib文件(在Project属性中,我只设置.lib路径并"手动"加载libs,如标题):
#pragma once
#ifndef PCLTEST_LIBS
#define PCLTEST_LIBS
#ifdef _DEBUG
#pragma comment(lib, "pcl_apps-gd.lib")
#pragma comment(lib, "pcl_common-gd.lib")
// a bunch of other debug libs
#else
// the release libs
#endif
#endif
Run Code Online (Sandbox Code Playgroud)
一个主文件,我基本上删除了此时调试的所有内容:
// load the libs
#ifndef PCLTEST_LIBS
#include "libs.h"
#endif
// pcltest includes
// if only this first one is #included, everything is OK
#include "opencvOperations.h"
// #including this one causes the error
#include "files.h"
// these ones are not working also
//#include "cloudOperations.h"
//#include "visualize.h"
// c++ headers
#include <stdio.h>
#include <string>
//#include <sstream>
//#include <iostream>
void writeInfo()
{
// some std::cout calls
}
int main( int argc, char* argv[] )
{
writeInfo();
// this function is in opencvOperations.h and works OK
pcltest::openLena();
}
Run Code Online (Sandbox Code Playgroud)
然后我在main.obj中收到一些错误消息,其中一些(PCL相关的)符号已在files.obj中定义.我在opencvOperations和文件中使用PCL相关的调用,第一个是OK,第二个不起作用.
编辑: 要添加更多细节,我的files.h标题:
#pragma once
#ifndef PCLTEST_FILES
#define PCLTEST_FILES
// pcl headers
#ifndef PCL_COMMON_H_
#include <pcl/common/common_headers.h>
#endif
#ifndef PCL_IO_FILE_IO_H_
#include <pcl/io/file_io.h>
#endif
#ifndef PCL_IO_PCD_IO_H_
#include <pcl/io/pcd_io.h>
#endif
#ifndef PCL_IO_PLY_IO_H_
#include <pcl/io/ply_io.h>
#endif
// boost headers
#ifndef BOOST_FILESYSTEM_OPERATIONSX_HPP
#include <boost/filesystem/operations.hpp>
#endif
#endif
namespace pcltest
{
// function to open PCL or binary PLY files
pcl::PointCloud<pcl::PointXYZ>::Ptr openCloud(std::string filename);
// function to save the point cloud to PCD format
void saveCloud();
}
Run Code Online (Sandbox Code Playgroud)
在将代码拆分为单独的文件之前,一切都运行良好(使用相同的项目设置).
EDIT2:
我找到了问题的根源,
#include <pcl/io/ply_io.h>
Run Code Online (Sandbox Code Playgroud)
导致这个.现在,我摆脱了与PLY相关的一切,一切正常.我稍后会看一下,这可能是PCL库特定的问题.我仍然很奇怪为什么这个调用导致另一个文件中的链接器错误,我甚至不使用PLY相关的函数/变量.
小智 8
我遇到了和你一样的问题.我有一个surface.h和surface.cpp文件,我发现我必须包括surface.cpp而不是surface.h的ply_io.h文件,现在它编译得很好.我希望这有帮助或有意义!哈哈