首页 > 解决方案 > MonetDB 客户端编译

问题描述

我是数据库社区的初学者。我一直在尝试使用 C/C++ MAPI与 MonetDB 交互。我已经在我的 Ubuntu 14.04 LTS 机器上安装了 MonetDB,当我尝试从这里编译示例程序时,我收到以下错误:

$ gcc test.c -I /usr/include/monetdb -lmapi

test.c:(.text+0x29): undefined reference to mapi_explain_query' test.c:(.text+0x35): undefined reference tomapi_result_error' test.c:(.text+0x50): undefined reference to mapi_explain_result' test.c:(.text+0x5c): undefined reference tomapi_next_result' test.c:(.text+0x6d): undefined reference to mapi_close_handle' test.c:(.text+0x79): undefined reference tomapi_destroy' test. c:(.text+0x98): 未定义引用mapi_explain' test.c:(.text+0xa4): undefined reference tomapi_destroy' /tmp/cctyQopc.o: 在函数query': test.c:(.text+0xf9): undefined reference tomapi_query' test.c:(.text+0x110): 未定义引用mapi_error' /tmp/cctyQopc.o: In function更新': test.c:(.text+ 0x160): 未定义引用mapi_close_handle' /tmp/cctyQopc.o: In functionmain': test.c:(.text+0x1b6): 未定义引用mapi_connect' test.c:(.text+0x1c6): undefined reference tomapi_error' test.c:(.text+0x238): 未定义引用mapi_fetch_field' test.c:(.text+0x24d): undefined reference tomapi_fetch_field' test.c:(.text+0x277 ):对mapi_fetch_row' test.c:(.text+0x287): undefined reference tomapi_close_handle 的未定义引用 test.c:(.text+0x293):对“mapi_destroy”collect2 的未定义引用:错误:ld 返回 1 个退出状态

这个问题以前在这里被问过,答案并没有解决问题(虽然答案被接受了,我不知道为什么)。任何帮助/方向都会很棒!

标签: cdatabasemonetdb

解决方案


在 Ubuntu 18.04 上使用:

pkg-config --libs monetdb-mapi 和 pkg-config --cflags monetdb-mapi

无法工作,因为 Ubuntu 没有 bzip2.pc:

它是如何工作的:

gcc main.c -I /usr/include/monetdb -lmapi -lssl -lcrypto -lstream -lcurl -llzma -lbz2


推荐阅读