0

I tried to compile test application for MonetDB under Ubuntu 14.04 LTS Trusty Tahr. I followed the download instructions from official site, installation was successful, then I installed a bunch of other packages in order to copmpile it. Now when I try to compile and link test application I get the following errors:

libtool: compile:  gcc -c -I/usr/include/monetdb test.c  -fPIC -DPIC -o .libs/test.o
libtool: compile:  gcc -c -I/usr/include/monetdb test.c -o test.o >/dev/null 2>&1
libtool: link: gcc -o test test.o  -lmapi -lstream -lssl -lcrypto -lcurl -lz
test.o: In function `die':
test.c:(.text+0x1c): undefined reference to `mapi_explain_query'
test.c:(.text+0x27): undefined reference to `mapi_result_error'
test.c:(.text+0x3f): undefined reference to `mapi_explain_result'
test.c:(.text+0x4a): undefined reference to `mapi_next_result'
test.c:(.text+0x5a): undefined reference to `mapi_close_handle'
test.c:(.text+0x65): undefined reference to `mapi_destroy'
test.c:(.text+0x81): undefined reference to `mapi_explain'
test.c:(.text+0x8c): undefined reference to `mapi_destroy'
test.o: In function `query':
test.c:(.text+0xde): undefined reference to `mapi_query'
test.c:(.text+0xf2): undefined reference to `mapi_error'
test.o: In function `update':
test.c:(.text+0x133): undefined reference to `mapi_close_handle'
test.o: In function `main':
test.c:(.text+0x190): undefined reference to `mapi_connect'
test.c:(.text+0x1a0): undefined reference to `mapi_error'
test.c:(.text+0x222): undefined reference to `mapi_fetch_field'
test.c:(.text+0x23a): undefined reference to `mapi_fetch_field'
test.c:(.text+0x266): undefined reference to `mapi_fetch_row'
test.c:(.text+0x276): undefined reference to `mapi_close_handle'
test.c:(.text+0x282): undefined reference to `mapi_destroy'
collect2: error: ld returned 1 exit status
./t.sh: 11: ./t.sh: ./test: not found

What I'm doing wrong? What should I additionally install or change in compilation options for successful linking of test example?

Rickest Rick
  • 1,519
  • 1
  • 15
  • 28
Ivan Zuboff
  • 47
  • 1
  • 9

2 Answers2

0

I was able to compile the example on Ubuntu 14.04 with MonetDB installed from the Ubuntu binary packages after installing the (additional) package libmonetdb-client-dev with the following command:

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

Did you compile and install MonetDB from source? In this case, which prefix was used?

Hannes Mühleisen
  • 2,542
  • 11
  • 13
  • I used binary packages from official MonetDB repository. Unfortunately, your variant didn't solved a problem for me, but big thanks for help anyway! I think I'll just move to PostgreSQL to fix this problem :) – Ivan Zuboff Feb 11 '16 at 16:27
  • So what's the issue now? – Hannes Mühleisen Feb 12 '16 at 08:49
  • When I tried your command for compilation, errors was the same: multiplie "undefined reference to `mapi_XXXXX'" errors. – Ivan Zuboff Feb 12 '16 at 11:05
  • Yes, I've surely installed it (I've run apt-get to install that package and later seen it in synaptic package manager as installed). Thank you for help, Hannes! I think that it's something wrong with my copy of OS, if you can successfully do the compilation on the same version of same distibution. – Ivan Zuboff Feb 12 '16 at 21:32
0

Here how it worked using ubuntu 18.04

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