2014-07-12 86 views
2

我正在創建一個需要使用libnoise頭文件的項目。但是我編譯有困難。在Eclipse中設置庫CDT

我已經把標題到我的項目我的src /目錄,所以我可以將它們包括與

#include "noise/noise.h" 
#include "noise/noisegen.h" 
#include "noiseutils.h" 

但是當我嘗試創建一個柏林模塊noise::module::Perlin perlinModule;,我得到以下編譯錯誤:

PROJECTDIR\bin/../src/libnoise_wrapper.cpp:66: undefined reference to `noise::module::Perlin::Perlin()' 
./src/libnoise_wrapper.o: In function `~Perlin': 
PROJECTDIR\bin/../src/noise/module/perlin.h:160: undefined reference to `vtable for noise::module::Perlin' 
PROJECTDIR\bin/../src/noise/module/perlin.h:160: undefined reference to `noise::module::Module::~Module()' 
PROJECTDIR\bin/../src/noise/module/perlin.h:160: undefined reference to `vtable for noise::module::Perlin' 
PROJECTDIR\bin/../src/noise/module/perlin.h:160: undefined reference to `noise::module::Module::~Module() 

我已經創建了一個項目包括參考/ SRC /噪聲文件夾以及文件noiseutils.h(這是在src /目錄本身)。

有沒有其他配置我缺少?

+1

可能的重複[什麼是未定義的引用/無法解析的外部符號錯誤,以及如何解決它?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-外部符號錯誤和怎麼辦我修復) –

+1

@πάνταῥεῖ:請停止downvoting和關閉投票一切都有表達「無法解析的外部符號」與明顯不好的「規範重複」。這不是建設性的。即使設法關閉,我也會立即重新打開它,並重新進行綁定。 – lpapp

回答

1

"I have put the headers into my src/ directory of my project, so I am able to include them with "

這不是通常的做法!你應該有這個庫的安裝在您的環境(也有一些說明如何爲你在這個tutorial from the libnoise online documentation提供特定的情況下做到這一點),並添加附加包含路徑使用

Project Properties->C/C++ Build->Settings-><actual C++ Compiler>->Includes->Include paths (-I) 

enter image description here 設置搜索。

"Are there any other configurations I am missing?"

檢查

Project Properties->C/C++ Build->Settings-><actual toolchain linker>->Libraries 

enter image description here

屬性頁。

您需要在Libraries列表中提供noise列表,最後還需要提供一個指向實際庫安裝的附加Library search path。後者取決於你的環境中安裝libnoise的方式和位置。

+0

我不得不編譯libnoise庫(請參閱http://stackoverflow.com/questions/13280932/compiling-libnoise-on-windows-with-mingw)以便能夠鏈接它,這使得頭文件無用。但它的工作,感謝或幫助。 – Sash

+0

出於好奇,你爲什麼不自己使用頭,而不是編譯庫? – Sash

+2

@Sash一般來說,你有2個選擇:1.爲當前具有二進制文件的環境安裝庫。 2.編譯(並安裝)當前環境的庫(這會生成正確的二進制文件)。這兩種方法都只是使用頭文件,包含庫二進制文件中必需的聲明,以便與應用程序鏈接。 –