2010-08-24 202 views
0

我是新来东京内阁和我已经安装了它,我已经运行示例C程序我得到错误... 而我用gcc编译编译问题

gcc -O tcadbex.c 

/tmp/cc7IEOht.o: In function `main': 
tcadbex.c:(.text+0xd): undefined reference to `tcadbnew' 
tcadbex.c:(.text+0x1f): undefined reference to `tcadbopen' 
tcadbex.c:(.text+0x58): undefined reference to `tcadbput2' 
tcadbex.c:(.text+0x74): undefined reference to `tcadbput2' 
tcadbex.c:(.text+0x90): undefined reference to `tcadbput2' 
tcadbex.c:(.text+0xc1): undefined reference to `tcadbget2' 
tcadbex.c:(.text+0x10e): undefined reference to `tcadbiterinit' 
tcadbex.c:(.text+0x11c): undefined reference to `tcadbget2' 
tcadbex.c:(.text+0x156): undefined reference to `tcadbiternext2' 
tcadbex.c:(.text+0x164): undefined reference to `tcadbclose' 
tcadbex.c:(.text+0x18d): undefined reference to `tcadbdel' 
collect2: ld returned 1 exit status 

能任何人告诉我这是什么问题...

回答

1

是的,你几乎肯定会与东京Cabinate的库文件(不管是什么)。

通常情况下,你可以使用像这样的命令:

gcc -o tcadbex -L/usr/lib -lxyz tcadbex.c 

其中:

  • -L指定库搜索路径。
  • -l列出要搜索未定义符号的库。

和连接器会去寻找库,按照一定的规则进行车削xyz到一个文件名类似libxyz.so

事实上,搜索网上的轮番上涨this(在同一行,我只是分裂它的可读性):

gcc -I/usr/local/include tc_example.c -o tc_example 
    -L/usr/local/lib -ltokyocabinet -lz -lbz2 -lrt -lpthread -lm -lc 

的命令行使用。

,所以我建议你需要为你的具体情况(再次,在一行上):

gcc -I/usr/local/include tcadbex.c -o tcadbex 
    -L/usr/local/lib -ltokyocabinet -lz -lbz2 -lrt -lpthread -lm -lc 
+0

我得到这个,如果我运行上面的CMD ..但我的Java API工作正常,,,但我需要它在c /usr/bin/ld:无法找到-ltcadb collect2:ld返回1退出状态 – raj 2010-08-24 08:24:52

+0

@raj,检查更新,库有一个不同的名称,我用作为一个例子。 – paxdiablo 2010-08-24 08:27:08