2010-08-24 203 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