tokyo cabate C程序的编译问题

发布于 2024-09-15 21:39:25 字数 867 浏览 8 评论 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

任何人都可以告诉我这有什么问题吗?

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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好倦 2024-09-22 21:39:25

是的,您几乎肯定必须链接到 Tokyo Cabinate 的库文件(无论是什么)。

通常,您将使用如下命令:

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

其中:

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

链接器将按照一定的规则寻找库,将 xyz 转换为 libxyz.so 这样的文件名。

事实上,在网络上搜索会发现这个(在一行中,我'我只是为了可读性而将其拆分):

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文