2011-03-21 153 views
0

我已經在/opt/hypertable/current/安裝Hypertable的,我逃離Hypertable的一個示例程序...Hypertable的庫鏈接問題

#include <Common/Compat.h> 

#include <iostream> 
#include <fstream> 
#include <string> 

#include <Common/System.h> 
#include <Common/Error.h> 

#include <Hypertable/Lib/Client.h> 
#include <Hypertable/Lib/KeySpec.h> 

using namespace Hypertable; 

int main(int argc, char* argv[]) { 
     ClientPtr client_ptr; 
     TablePtr table_ptr; 
     TableMutatorPtr mutator_ptr; 
     KeySpec key; 

     const char* install_dir = "/opt/hypertable/current/"; 

     client_ptr = new Client(System::locate_install_dir(install_dir)); 

} 

我得到這個錯誤

g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/testes.d" -MT"src/testes.d" -o"src/testes.o" "../src/testes.cpp" 
../src/testes.cpp:1: fatal error: Common/Compat.h: No such file or directory 

我使用的Eclipse CDT我的發展,我鏈接使用項目Properties->c/c++build->setting->Libraries->LibrarySetPath(-L)和我已經簽署了HyperCommon also in -l這我把它設置爲/opt/hypertable/current/include/任何一個可以告訴我,我得到這個錯誤...

回答

0

建立軟件時需要設置兩個不同的路徑:包括路徑和路徑。你似乎混淆了他們。

包含路徑是找到所有.h文件的路徑。如果你有一個包含路徑的問題,它會在編譯時出現(當你構建每個單獨的.o文件時),這就是你所看到的。 「Common/Compat.h:沒有這樣的文件或目錄」意味着你很可能缺少包含路徑。

庫路徑是在鏈接時查找DLL /共享對象文件的路徑。如果你有一個庫路徑問題,它會在鏈接時出現(當從.o文件創建最終的可執行文件時)。你沒有達到編譯的階段。

這樣做LibrarySetPath和設置-l-L是一個鏈接器/庫的東西;你想修復包含路徑。

很可能,您希望將/opt/hypertable/current/include/添加到包括路徑(在Eclipse中)。在GCC命令行上,這將通過-I /opt/hypertable/current/include/而不是-L完成。

+0

我如何在eclipse中添加-I選項 – raagavan 2011-03-21 04:14:14

+0

我不使用Eclipse,抱歉。在C++構建設置中應該有一個名爲「包含路徑」的地方(類似於你找到「庫路徑」的地方),這就是你應該把它放在哪裏。 – mgiuca 2011-03-22 10:49:58

-1

你想添加/ opt/hypertable/current/include/ThriftBroker/gen-cpp到包含路徑 你還得一起編譯/ opt/hypertable/current/include/ThriftBroker/gen-cpp下的cpp文件