2011-03-21 242 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文件