tags:

views:

20

answers:

1

hello, i am new to tokyo cabinet and i have installed it and i have run the example c program i am getting error... while i compile with 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

can any one tell me what is the issues with this...

+1  A: 

Yes, you will almost certainly have to link with the library files for Tokyo Cabinate (whatever that is).

Typically, you would use a command like:

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

where:

  • -L specifies search paths for libraries.
  • -l lists libraries to search for undefined symbols.

and the linker will go looking for the libraries, following certain rules for turning xyz into a file name like libxyz.so.

In fact, a search of the net turns up this (on one line, I'm just splitting it for readability):

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

as the command line to use.

so I would suggest that you need for your specific case (again, on one line):

gcc -I/usr/local/include tcadbex.c -o tcadbex
    -L/usr/local/lib -ltokyocabinet -lz -lbz2 -lrt -lpthread -lm -lc
paxdiablo
i get this if i run the above cmd ..but my java api works fine,,, but i need it in c/usr/bin/ld: cannot find -ltcadbcollect2: ld returned 1 exit status
raj
@raj, check the update, the library has a different name to the one I used as an example.
paxdiablo