Undefined references everywhere, while trying to compile BluezTools? - c

I'm trying to compile BluezTools using the following command:
./autogen.sh && ./configure && make
Here is a snippet of the output:
obextransfer.c:(.text+0x4d5): undefined reference to `g_type_check_instance_cast'
obextransfer.c:(.text+0x4f1): undefined reference to `dbus_g_proxy_disconnect_signal'
obextransfer.c:(.text+0x4fd): undefined reference to `g_object_unref'
obextransfer.c:(.text+0x50a): undefined reference to `g_free'
obextransfer.c:(.text+0x517): undefined reference to `g_object_unref'
obextransfer.c:(.text+0x528): undefined reference to `g_type_check_class_cast'
lib/obexd/obextransfer.o: In function `obextransfer_cancel':
obextransfer.c:(.text+0x56a): undefined reference to `g_type_check_instance_is_a'
obextransfer.c:(.text+0x58a): undefined reference to `g_assertion_message_expr'
lib/obexd/obextransfer.o: In function `obextransfer_get_dbus_object_path':
obextransfer.c:(.text+0x5e2): undefined reference to `g_type_check_instance_is_a'
obextransfer.c:(.text+0x602): undefined reference to `g_assertion_message_expr'
lib/obexd/obextransfer.o: In function `_obextransfer_get_property':
obextransfer.c:(.text+0x64f): undefined reference to `g_type_check_instance_cast'
obextransfer.c:(.text+0x660): undefined reference to `g_type_name'
obextransfer.c:(.text+0x66f): undefined reference to `g_type_name'
obextransfer.c:(.text+0x6a3): undefined reference to `g_log'
lib/obexd/obextransfer.o: In function `progress_handler':
obextransfer.c:(.text+0x4af): undefined reference to `g_signal_emit'
lib/obexd/obextransfer.o: In function `obextransfer_cancel':
obextransfer.c:(.text+0x5ad): undefined reference to `dbus_g_proxy_call'
lib/obexd/obextransfer.o: In function `obextransfer_get_dbus_object_path':
obextransfer.c:(.text+0x619): undefined reference to `dbus_g_proxy_get_path'
lib/obexd/obextransfer.o: In function `_obextransfer_get_property':
obextransfer.c:(.text+0x6e7): undefined reference to `g_value_set_string'
collect2: error: ld returned 1 exit status
make[2]: *** [bt-monitor] Error 1
make[2]: Leaving directory `/home/[]/Downloads/bluez-tools-bluez-tools/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/[]/Downloads/bluez-tools-bluez-tools
This is my first attempt as building a C project on Linux, where am I going wrong?
Running Linux Mint 15 Olivia 64bit.

Do you have bluez and obexd installed? https://code.google.com/p/bluez-tools/#Requirements
You could check the output of ./configure for any errors. Usually there is a configure.log or similar to grep for erros.
I dont know about Mint package management, but you probably need some kind of obex*-dev package at least or install obex source yourself.
EDIT Edited to answer the comment.
I do not think the obexd-client is enough, but try this method and see if it is. Otherwise you need to look for some -dev packages like libglib2.0-cil-dev libglib2.0-dev and libdbus-glib-1-dev. (Those are the names on Ubuntu).
Here is how I got it to compile (still emits warnings, though).
Install a bunch of -dev packages for glib and dbus (ddg/google the functions that fail to link, so you see which libraries they are from).
Execute pkg-config --libs --cflags dbus-1 dbus-glib-1 glib-2.0
Use the output of the command in the ./configure e.g.:
env LIBS="-I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0" ./configure
Execute make
See also this question: Compilation error dbus-ping-pong

Fixed a similar problem by adding pkg-config --libs gtk+-2.0. Maybe helps someone.

Related

Undefined reference to `__gmpz and makefile

I can’t figure out why I’m getting these compilation errors:
gcc -o Compil obj/MillerRabin.o obj/main.o -L. -L/usr/lib/ -Wl,-rpath=/home/---------/Documents/AC20_Cyrpto -lgmp -lCommon -ltest -lprimeGen
./libtest.so: undefined reference to `__gmpz_set_str'
./libtest.so: undefined reference to `__gmpz_set_ui'
./libtest.so: undefined reference to `__gmpz_add_ui'
./libtest.so: undefined reference to `__gmpz_clear'
./libtest.so: undefined reference to `__gmpz_init'
./libtest.so: undefined reference to `mpzPrint'
collect2: error: ld returned 1 exit status
Makefile:61: recipe for target 'Compil' failed
make: *** [Compil] Error 1
These errors are coming from libs/test/test.c, I’m using a make file that a friend of mine made, and I haven’t really looked into how they work yet.
So what’s weird is that in my libs folder I have another .c file that’s using gmp (libs/Common/common.h and mpzfunctions.c), and that one doesn’t give me any errors. If I move my test function to the main the compilation works.
If anyone knows how to fix this, it would be great! Thanks.
Symbols from libraries are applied in order. So when you write:
-lgmp -ltest
It means that symbols used in libgmp will be looked up in libtest but not vice versa.
Apparently, your libtest requires functions from libgmp, so you need to apply them in the opposite order.
As a rule of thumb, external libraries should always go last because they do not generally require symbols from your libraries.
So without knowing too much, I 'd guess that the order should be:
-lCommon -lprimeGen -ltest -lgmp
It looks to me like you will want to remove -lgmp from LINK_FLAGS and add it somehow to the end of the link command.

Issue with linking libraries built with gnat

When trying to build some test cases (just programs written in Ada), I get the following error:
gcc -c -shared decimaltests.adb
gnatbind -x decimaltests.ali
gnatlink decimaltests.ali -lGenerics -lNumerics -lTesting
/usr/bin/ld: decimaltests: hidden symbol `_Unwind_Resume' in
/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1/libgcc_eh.a(unwind-dw2.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
gnatlink: error when calling /usr/bin/gcc
gnatmake: *** link failed.
I'm building them with gnatmake -shared *.ad{b,s} -largs -lGenerics -lNumerics -lTesting Clearly this isn't a problem with building the sources, but just to further confirm that, I copied the sources into this directory and built using gnatmake -shared *.ad{b,s} which built the tests just fine.
The dependent libraries are built and installed into a path gnat searches through. It doesn't seem to be an issue of not finding those. Not sure what's going on here.
All the libraries are built with gnatmake -O2 -fPIC -shared *.ad{b,s} as well as any relevant library dependencies. All libraries that depend on these can still be built. It's only even programs that depend on the libraries that throw this error, and always the same error.
Update: Building the libraries using gprbuild and then installing them with gprinstall seems to work similarly, except now the error is as follows:
decimaltests.o: In function `_ada_decimaltests':
decimaltests.adb:(.text+0x43): undefined reference to `testing__start'
decimaltests.adb:(.text+0x4a): undefined reference to
`generics__testing__default_tolerance'
decimaltests.adb:(.text+0x9e): undefined reference to
`generics__testing__default_tolerance'
decimaltests.adb:(.text+0x108): undefined reference to
`generics__testing__default_tolerance'
decimaltests.adb:(.text+0x172): undefined reference to
`generics__testing__default_tolerance'
decimaltests.adb:(.text+0x1dc): undefined reference to
`generics__testing__default_tolerance'
decimaltests.o:decimaltests.adb:(.text+0x23f): more undefined references to
`generics__testing__default_tolerance' follow
decimaltests.o: In function `_ada_decimaltests':
decimaltests.adb:(.text+0x14f5): undefined reference to `testing__stop'
/usr/lib/numerics//libNumerics.so: undefined reference to
`generics__testing__not_started#SYMS'
/usr/lib/numerics//libNumerics.so: undefined reference to
`generics__testing__pass#SYMS'
/usr/lib/numerics//libNumerics.so: undefined reference to
`generics__testing__fail#SYMS'
collect2: error: ld returned 1 exit status
gprbuild: link of decimaltests.adb failed
So I looked through the symbols table for both build methods and noticed, in both cases, the symbol most definitely exists, but the reference to it seems to be the wrong location. I'll try building on different platforms/compilers and update again if anything relevant comes up.
Both processes correctly build the libraries and test programs, and the test programs run properly, on different platforms. To further confirm that this is a bug, I've installed a different GCC toolchain and repeated the builds under the original platform, and this problem did not arise. I'll be filing a bug report.

Undefined reference, WebKitGTK

Well, I'm trying to compile a simple program, embedding the WebView of WebKit in a GTK Window. So, when the compiler check this line:
webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
It gave me some errors:
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `cairo_gl_surface_get_width'
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `cairo_egl_device_create'
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `soup_message_set_priority'
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `hb_icu_get_unicode_funcs'
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `cairo_glx_device_create'
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `cairo_gl_surface_get_height'
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `cairo_gl_device_set_thread_aware'
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `cairo_gl_surface_create_for_texture'
/usr/local/lib/libwebkitgtk-3.0.so: undefined reference to `hb_icu_script_to_script'
collect2: error: ld returned 1 exit status
make[2]: ** [dist/Debug/GNU-Linux-x86/webkittest] Erro 1
make[2]: Saindo do diretório `/home/todi/Projetos/Cpp/WebKitTest'
make[1]: ** [.build-conf] Erro 2
make[1]: Saindo do diretório `/home/todi/Projetos/Cpp/WebKitTest'
make: ** [.build-impl] Erro 2
Yes, I have did the reference to the lib in the linker and I don't know where to find these functions. I'll appreciate your help!
Thanks!
This was fixed in later version of webkit-gtk. See https://bugs.webkit.org/show_bug.cgi?id=108174: either downgrade harfbuzz to compile this version of webkit-gtk, or upgrade webkit-gtk to the lastets version (works fine with 2.4.3)
compile harfbuzz with
sudo ./configure --with-icu
sudo make
sudo make istall
and then compile cairo with
sudo ./configure --enable-gl --includedir="/usr/include/" --libdir="/usr/share/lib"
sudo make
sudo make install

libcurl curl/curl.h No such file or Directory Win xp 32 MinGW

I have been searching for a couple of hours and found several threads with the same problem and tried all their suggestions.
My curl.h is in C:\MinGW\msys\1.0\curl-7.29.0\include\curl and I've included it at compile time but for some reason gcc claims it can't find it:
gcc -o curl.exe curl.c -IC:/MinGW/msys/1.0/local/ -IC:/MinGW/msys/1.0/curl-7.29.0/lib/.libs/ -IC:/MinGW/msys/1.0/curl-7.29.0/include/curl -IC:/MinGW/msys/1.0/OpenSSL-Win32/ -lcurl -lws2_32
and the result:
curl.c:4:32: fatal error: curl/curl.h: No such file or directory
UPDATE: (With the suggestion from H2CO3)
$ gcc -o curl.exe curl.c -IC:/MinGW/msys/1.0/local -IC:/MinGW/msys/1.0/curl-7.29.0/lib/.libs/ -IC:/MinGW/msys/1.0/curl-7.29.0/include/ -IC:/MinGW/msys/1.0/OpenSSL-Win32/include/ -lws2_32
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0xa8): undefined reference to `_imp__curl_global_init'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0xe6): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x124): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x162): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x169): undefined reference to `_imp__curl_easy_init'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x183): undefined reference to `_imp__curl_slist_append'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x1b8): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x211): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x237): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x245): undefined reference to `_imp__curl_easy_perform'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x25e): undefined reference to `_imp__curl_easy_strerror'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x288): undefined reference to `_imp__curl_easy_cleanup'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x296): undefined reference to `_imp__curl_formfree'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x2a4): undefined reference to `_imp__curl_slist_free_all'
collect2: ld returned 1 exit status
If I try to compile with -lcurl it says ..... ld.exe: cannot find -lcurl is this because it can't find the dll?
You're including <curl/curl.h>, and not <curl.h>. So you have to tell the compiler to look for header files in the include directory, and not in include/curl:
gcc -IC:\MinGW\msys\1.0\curl-7.29.0\include etc. etc.
This might be beyond the scope of what you're doing, but, I found it best to install a version of cURL(libcurl) into the MinGW/MSYS environment. After installed, any program can be compiled to use it with the typical <curl/curl.h> and -lcurl conventions since it's installed where GCC would expect it. I documented my process here.

Which library shall I add to get fcntl64, stat64, ... resolved?

I'm trying to build a project for ARM uClibc environment, but I've some functions missing. Can not find which library shall I include to resolve dependancies. nm do not help me to search, since it says on most of libs coming with toolchain:
nm: ./host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libuClibc-0.9.32.1.so: no symbols
Here is the output from GCC:
./host/usr/bin/arm-unknown-linux-uclibcgnueabi-gcc
-Wl,-rpath,./host/usr/lib/
-Wl,-rpath,./host/usr/../lib/
-Wl,-rpath,./host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/
-Llibzway -o test_so main.o -lzway
-L./host/usr/lib/
-L./host/usr/../lib/
-L./host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/ -lpthread
-lxml2 -lz -lm
./host/usr/lib/libxml2.so: warning: gethostbyname is obsolescent, use getnameinfo() instead.
./host/usr/lib/libxml2.so: undefined reference to `fcntl64'
./host/usr/lib/libxml2.so: undefined reference to `fopen64'
./host/usr/../lib/libz.so: undefined reference to `lseek64'
./host/usr/lib/libxml2.so: undefined reference to `stat64'
./host/usr/lib/libiconv.so.2: undefined reference to `mbrtowc'
./host/usr/lib/libiconv.so.2: undefined reference to `_stdlib_mb_cur_max'
./host/usr/lib/libiconv.so.2: undefined reference to `wcrtomb'
./host/usr/lib/libxml2.so: undefined reference to `open64'
collect2: ld returned 1 exit status
make: *** [test_so] Error 1
UPD:
I've copied uClibc from the target host and explicitely defined asked to link with it:
./host/usr/bin/arm-unknown-linux-uclibcgnueabi-gcc
-Wl,-rpath,./host/usr/lib/
-Wl,-rpath,./host/usr/../lib/
-Wl,-rpath,./host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/
-Llibzway -o test_so main.o -lzway
-L./host/usr/lib/
-L./host/usr/../lib/
-L./host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib/
-luClibc-0.9.31
-lpthread -lxml2 -lz -lm
./host/usr/bin/../lib/gcc/arm-unknown-linux-uclibcgnueabi/4.5.3/../../../../arm-unknown-linux-uclibcgnueabi/bin/ld:
errno: TLS reference in ./host/usr/bin/../arm-unknown-linux-uclibcgnueabi/sysroot/lib/libpthread.so.0 mismatches non-TLS definition in ./host/usr/lib/libuClibc-0.9.31.so section .bss
./host/usr/bin/../arm-unknown-linux-uclibcgnueabi/sysroot/lib/libpthread.so.0: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [test_so] Error 1
This is much bayond my knowledge of cross-compilation. Any idea?
It sounds like you have several issues going on:
You seem to be trying to use the host's copy of libxml2.so. This is not going to work. You need one built for your target system and its libc.
Your uClibc was compiled without large file support. Go back and fix the build options or uClibc. It's not strictly necessary (a correctly built libxml2.so linked against uClibc will work without doing this), but using the pre-large-file interfaces is really backwards and will unnecessarily limit your programs.

Resources