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?
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?
Here how it worked using ubuntu 18.04
gcc main.c -I /usr/include/monetdb -lmapi -lssl -lcrypto -lstream -lcurl -llzma -lbz2
Related
I seem to be having an issue building the ethping executable. It cannot find any of the functions that are defined in pcap.h.
At first I thought it wasn't finding pcap.h, but I have checked the $PATH and /usr/include is there (the pcap.h there is a stub that then includes pcap/pcap.h, but that looks all good too).
I even tried -I /usr/include and -I /usr/include/pcap, but still no luck.
I have searched through tons of forum postings, but could not find a solution. So that's why I am here. Any ideas?
root:src# gcc -Wall -Werror -ggdb -g -O2 -lpcap -o ethping ethping.o ieee8021ag.o dot1ag_eth.o
ethping.o: In function `timeout_handler':
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:65: undefined reference to `pcap_breakloop'
ethping.o: In function `main':
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:183: undefined reference to `pcap_open_live'
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:202: undefined reference to `pcap_compile'
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:203: undefined reference to `pcap_setfilter'
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:254: undefined reference to `pcap_next_ex'
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:257: undefined reference to `pcap_perror'
collect2: error: ld returned 1 exit status
Similarly:
root:src# gcc -Wall -Werror -ggdb -g -O2 -lpcap -I /usr/include/pcap -o ethping ethping.o ieee8021ag.o dot1ag_eth.o
ethping.o: In function `timeout_handler':
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:65: undefined reference to `pcap_breakloop'
ethping.o: In function `main':
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:183: undefined reference to `pcap_open_live'
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:202: undefined reference to `pcap_compile'
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:203: undefined reference to `pcap_setfilter'
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:254: undefined reference to `pcap_next_ex'
/home/ubuntu/Downloads/dot1ag-utils-master/src/ethping.c:257: undefined reference to `pcap_perror'
collect2: error: ld returned 1 exit status
root:src#
Changing the compile line fixed it. Placing -lpcap at the far right got it going as suggested.
gcc -Wall -Werror -ggdb -g -O2 -o ethping ethping.o ieee8021ag.o dot1ag_eth.o -lpcap
Either you are invoking the linker without the arguments to include the libpcap library, or the libraries are not installed. See http://www.tcpdump.org/ to obtain the library. Or if you are on a well-supported distribution, use the applicable install command:
sudo apt-get install libpcap-dev
or
sudo yum install libpcap-dev
i experience the undefined reference to `dlopen' problems since I have upgraded to ubuntu 13.10 and gcc 4.8.1.
The makefiles are working for years already. the particular call is
gcc -rdynamic -o ov_dbutil ov_dbutil.o libov.so -ldl
The errors are:
libov.so: undefined reference to `dlopen'
libov.so: undefined reference to `dlclose'
libov.so: undefined reference to `dlerror'
libov.so: undefined reference to `dlsym'
collect2: error: ld returned 1 exit status
make: *** [ov_dbutil] Error 1
is it a gcc problem?
ov_dbutil is compiled with the following lines
gcc -g -Wall -O0 -shared -std=c99 -fno-strict-aliasing -DPLT_SYSTEM_LINUX=1 -DPLT_USE_BUFFERED_STREAMS=1 -DPLT_SERVER_TRUNC_ONLY=1 -DNDEBUG -DOV_SYSTEM_LINUX=1 -I../../../plt/include/ -I../../../ks/include/ -I../../include/ -I../../model/ -I../../source/codegen/ -I../../source/builder/ -I../../source/example/ -I../../source/kshist/ -I../../source/dynov/ -I../../source/tasklib/ -I../../source/dbparse/ -I../../source/dbdump/ -I../../../../libml/ -I../../include/runtimeserver/ -I. -c ../../source/dbutil/ov_dbutil.c -o ov_dbutil.o
no errors or warnings
Add -Wl,--no-as-needed as linker arguments.
My issue was solved by adding -ldl in the lining line of the .so you want to link agains, it was called libov.so in the upper example.
Iam trying to compile the code example available on the libmosquitto website (at the bottom):
http://mosquitto.org/man/libmosquitto-3.html
Iam using Ubuntu 12.04 and I've installed libmosquitto1 and libmosquitto1-dev packages. Before installing them I added the mosquitto repository:
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
sudo apt-get update
Iam trying to compile the example as follows:
gcc -lmosquitto mosquito.c -o mosquito
But I get the following errors:
/tmp/cc6eU8kw.o: In function `my_connect_callback':
mosquito.c:(.text+0xf8): undefined reference to `mosquitto_subscribe'
/tmp/cc6eU8kw.o: In function `main':
mosquito.c:(.text+0x298): undefined reference to `mosquitto_lib_init'
mosquito.c:(.text+0x2b4): undefined reference to `mosquitto_new'
mosquito.c:(.text+0x310): undefined reference to `mosquitto_log_callback_set'
mosquito.c:(.text+0x324): undefined reference to `mosquitto_connect_callback_set'
mosquito.c:(.text+0x338): undefined reference to `mosquitto_message_callback_set'
mosquito.c:(.text+0x34c): undefined reference to `mosquitto_subscribe_callback_set'
mosquito.c:(.text+0x364): undefined reference to `mosquitto_connect'
mosquito.c:(.text+0x3b4): undefined reference to `mosquitto_loop'
mosquito.c:(.text+0x3c8): undefined reference to `mosquitto_destroy'
mosquito.c:(.text+0x3d0): undefined reference to `mosquitto_lib_cleanup'
collect2: ld returned 1 exit status
Can someone give me some tips on how to compile this simple example?
Thanks
You have to put the -lmosquitto at the end (after the source files).
gcc mosquito.c -lmosquitto -o mosquito
# or
gcc mosquito.c -o mosquito -lmosquitto
# or
gcc -o mosquito mosquito.c -lmosquitto
Or better:
gcc -Wall -Wextra -pedantic -o mosquito mosquito.c -lmosquitto
I use MinGW to create, and my lua version is 5.1.4 the followings are my steps:
swig -lua example.i
gcc -c example_wrap.c -I C:\Lua\5.1\include
gcc -c example.c -I C:\Lua\5.1\include
gcc -shared example_wrap.o example.o -o example.dll
errors ocurrs at last step, here are some part of the errors information
example_wrap.o:example_wrap.c:(.text+0x2aef): undefined reference to `lua_gettop'
example_wrap.o:example_wrap.c:(.text+0x2afe): undefined reference to `lua_gettop'
example_wrap.o:example_wrap.c:(.text+0x2b2d): undefined reference to `lua_pushfstring'
example_wrap.o:example_wrap.c:(.text+0x2b38): undefined reference to `lua_error'
example_wrap.o:example_wrap.c:(.text+0x2b67): undefined reference to `lua_pushnumber'
example_wrap.o:example_wrap.c:(.text+0x2ec0): undefined reference to `lua_pushvalue'
example_wrap.o:example_wrap.c:(.text+0x2ee3): undefined reference to `lua_pushstring'
example_wrap.o:example_wrap.c:(.text+0x2efe): undefined reference to `lua_pushcclosure'
example_wrap.o:example_wrap.c:(.text+0x2f11): undefined reference to `lua_rawset'
example_wrap.o:example_wrap.c:(.text+0x2f24): undefined reference to `lua_pushstring'
example_wrap.o:example_wrap.c:(.text+0x2f3f): undefined reference to `lua_pushcclosure'
example_wrap.o:example_wrap.c:(.text+0x2f52): undefined reference to `lua_rawset'
collect2: ld returned 1 exit status
it seems that I didn't include the lua header?
so I also try these commands but no use
gcc -shared example_wrap.o example.o -I C:\Lua\5.1\include -o example.dll
so any suggestions?
Try to link with this command:
gcc -LC:\Lua\5.1\bin -shared example_wrap.o example.o -llua51 -o example.dll
the path in the -LC:\Lua\5.1\bin part should point to the directory where you have your lua51.dll (I assumed bin, as in my system, but change it to suit your installation).
I just switched my dev machine from Gentoo to Arch Linux and, when I try to compile a fresh build of my project, linking fails:
clang -O0 -g -pipe -Wall -DDEBUG -o slug announce.o bitfield.o main.o metadata.o network.o parser.o peer.o piece.o scheduler.o torrent.o url.o util.o -I. -lssl -lm -lcurl -levent
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:186: error: undefined reference to 'SHA1_Init'
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:187: error: undefined reference to 'SHA1_Update'
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:188: error: undefined reference to 'SHA1_Final'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:40: error: undefined reference to 'SHA1_Init'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:41: error: undefined reference to 'SHA1_Update'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:42: error: undefined reference to 'SHA1_Final'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [slug] Error 1
The entire source is on GitHub: https://github.com/robertseaton/slug.
Looks like you're missing -lcrypto
From my experience, the location of -lssl or -lcrypto may be the source of the problem. Try to push -lcrypto option to the end of the gcc options, or before input object files.