问题
I'm a beginner in the Database community. I have been trying to interface with MonetDB using C/C++ MAPI. I have installed MonetDB on my Ubuntu 14.04 LTS machine and when I try to compile a sample program from here, I get the following error:
$ gcc test.c -I /usr/include/monetdb -lmapi
test.c:(.text+0x29): undefined reference to
mapi_explain_query' test.c:(.text+0x35): undefined reference to
mapi_result_error' test.c:(.text+0x50): undefined reference tomapi_explain_result' test.c:(.text+0x5c): undefined reference to
mapi_next_result' test.c:(.text+0x6d): undefined reference tomapi_close_handle' test.c:(.text+0x79): undefined reference to
mapi_destroy' test.c:(.text+0x98): undefined reference tomapi_explain' test.c:(.text+0xa4): undefined reference to
mapi_destroy' /tmp/cctyQopc.o: In functionquery': test.c:(.text+0xf9): undefined reference to
mapi_query' test.c:(.text+0x110): undefined reference tomapi_error' /tmp/cctyQopc.o: In function
update': test.c:(.text+0x160): undefined reference tomapi_close_handle' /tmp/cctyQopc.o: In function
main': test.c:(.text+0x1b6): undefined reference tomapi_connect' test.c:(.text+0x1c6): undefined reference to
mapi_error' test.c:(.text+0x238): undefined reference tomapi_fetch_field' test.c:(.text+0x24d): undefined reference to
mapi_fetch_field' test.c:(.text+0x277): undefined reference tomapi_fetch_row' test.c:(.text+0x287): undefined reference to
mapi_close_handle' test.c:(.text+0x293): undefined reference to `mapi_destroy' collect2: error: ld returned 1 exit status
This question has previously been asked here and the answer did not solve the problem (although the answer was accepted, I'm not sure why). Any help/directions would be great!
回答1:
On Ubuntu 18.04 using:
pkg-config --libs monetdb-mapi and pkg-config --cflags monetdb-mapi
Won't work because Ubuntu doesn't have a bzip2.pc:
Here how it worked:
gcc main.c -I /usr/include/monetdb -lmapi -lssl -lcrypto -lstream -lcurl -llzma -lbz2
来源:https://stackoverflow.com/questions/51644081/monetdb-client-compilation