2014-01-19 28 views
0

我想在我的代碼中的兩個源文件中使用pcl::io::savePNGFile在多個文件中包含<pcl/io/png_io.h>時發生鏈接錯誤

只要我有需要的包括第二源文件

# include <pcl/io/png_io.h> 

該項目不編譯。

的錯誤信息是:

/usr/include/pcl-1.7/pcl/io/png_io.h:86: multiple definition of `pcl::io::saveRgbPNGFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char const*, int, int)' 

我要去換行功能的一類,以包括只在項目一次。但我認爲這不是最好的方法。我是否以錯誤的方式做事?有更好的解決方案嗎?

謝謝!

EDIT

最後我實現的Q- & d溶液和包裹函數(僅在正常雲)

cloudsaver.h

#ifndef CLOUDSAVER_H 
#define CLOUDSAVER_H   

#include <pcl/point_types.h> 
#include <pcl/point_cloud.h> 
#include <string> 

class CloudSaver 
{ 

public: 
    CloudSaver(); 

    void saveCloudToPNG(const std::string & fileName, const pcl::PointCloud<pcl::PointXYZRGBNormal>& cl); 
}; 

#endif // CLOUDSAVER_H 

cloudsaver.cpp

#include "cloudsaver.h" 

# include <pcl/io/png_io.h> 

CloudSaver::CloudSaver() 
{ 

} 

void CloudSaver::saveCloudToPNG(const std::string & fileName, const pcl::PointCloud<pcl::PointXYZRGBNormal>& cl) 
{ 
    pcl::io::savePNGFile<pcl::PointXYZRGBNormal>(fileName, cl); 
} 

但我仍然好奇,如何正確地做到這一點。

回答

3

據我所知,有一些與png_io.h相關的問題。

我已經用這個定義改變了png_io.h文件中PCL_DEPRECATED的定義,並且每件事情都變好了。

template <typename T> 
PCL_DEPRECATED (void savePNGFile (const std::string& file_name, const pcl::PointCloud<T>&  cloud), 
"pcl::io::savePNGFile<typename T> (file_name, cloud) is deprecated, please use a new generic " 
"function pcl::io::savePNGFile (file_name, cloud, field_name) with \"rgb\" as the field name." 
); 

看看這個鏈接[https://github.com/PointCloudLibrary/pcl/pull/300]

+0

感謝您的信息!你知道嗎,如果這個函數被棄用,savePNG的替代品是什麼?我需要從定義的角度將雲視圖保存爲圖像。 –

+0

我發現了一個新的SavePNG函數,在這裏討論:[https://github.com/PointCloudLibrary/pcl/pull/204],代碼也在這裏,https://github.com/PointCloudLibrary/pcl/commit/9493da243331dd32f928f9c0a2e37101fe25bb29感謝PCL開發人員。 –

0

我猜你正在使用PCL的靜態版本。

要解決此問題,您需要聲明這些方法爲內聯

例如,對於PCL 1.7.1,你需要編輯這個文件: PCL-PCL-1.7.1/IO /包括/ PCL/IO/png_io.h

而在這些線路上,加關鍵字內聯:

85: inline saveRgbPNGFile(... 
96: inline savePNGFile(... 
107: inline savePNGFile(... 
119: inline savePNGFile(... 
173: inline savePNGFile(... 

現在重建庫,並且您應該能夠在沒有任何問題的情況下進行編譯。

相關問題