Contiki RTOS hello-world fails - c

Hello there I am trying to execute the example programs included as part of the Contiki RTOS package. I tried executing the hello-world program by using the command: make TARGET=cooja clean and then typed make TARGET=cooja, and this resulted in the following output on the terminal:
I../../core/loader -I../../core/. -DAUTOSTART_ENABLE -c hello-world.c -o hello-world.co
hello-world.c: In function ‘process_thread_hello_world_process’:
hello-world.c:52:3: warning: variable ‘PT_YIELD_FLAG’ set but not used [-Wunused-but-set-variable]
ld hello-world.co contiki-cooja.a -o hello-world.cooja
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048094
contiki-cooja.a(log.o): In function `simlog':
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:78: undefined reference to `strlen'
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:83: undefined reference to `strlen'
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:83: undefined reference to `memcpy'
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:84: undefined reference to `strlen'
contiki-cooja.a(log.o): In function `printf':
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:128: undefined reference to `vsnprintf'
make: *** [hello-world.cooja] Error 1
rm hello-world.co
root#ubuntu:/home/contiki/contiki-2.5/examples/hello-world#
Can someone please let me know as to where I am going wrong with the flow. I have made no changes to the original example codes and I intend to get the programs working on the COOJA simulator..thanks

Related

How to fix "undefined reference to 'something'" although all required files are already included? [duplicate]

This question already has answers here:
Why does the order in which libraries are linked sometimes cause errors in GCC?
(9 answers)
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 3 years ago.
Github :: https://github.com/mmgaggle/sslsqueeze
I am trying to build from source a code from github called "sslsqueeze". I have installed all required libraries but "make" command is still unable to link them for some reason. I am sure there is a very simple point/step I am missing here, but after hours of debugging, I am turning to you.
sslsqueeze.c file contains the line:
**sslsqueeze** needs to be linked with -levent_core from libevent2 library.
Accordingly I have installed libevent-dev library. And I run this command:
make
This is my list of errors :
sslsqueeze.o: In function `new_connection':
sslsqueeze.c:(.text+0x57): undefined reference to `bufferevent_socket_new'
sslsqueeze.c:(.text+0x68): undefined reference to `bufferevent_set_timeouts'
sslsqueeze.c:(.text+0x88): undefined reference to `bufferevent_setcb'
sslsqueeze.c:(.text+0x9d): undefined reference to `bufferevent_socket_connect'
sslsqueeze.o: In function `read_cb':
sslsqueeze.c:(.text+0x161): undefined reference to `bufferevent_read'
sslsqueeze.c:(.text+0x20d): undefined reference to `bufferevent_free'
sslsqueeze.c:(.text+0x25d): undefined reference to `bufferevent_write'
sslsqueeze.c:(.text+0x288): undefined reference to `bufferevent_write'
sslsqueeze.c:(.text+0x2b3): undefined reference to `bufferevent_write'
sslsqueeze.o: In function `event_cb':
sslsqueeze.c:(.text+0x2ed): undefined reference to `bufferevent_free'
sslsqueeze.o: In function `write_cb':
sslsqueeze.c:(.text+0x136): undefined reference to `bufferevent_enable'
sslsqueeze.o: In function `event_cb':
sslsqueeze.c:(.text+0x32c): undefined reference to `bufferevent_write'
sslsqueeze.o: In function `main':
sslsqueeze.c:(.text.startup+0x1f9): undefined reference to `event_base_new'
sslsqueeze.c:(.text.startup+0x229): undefined reference to `event_base_dispatch'
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'sslsqueeze' failed
make: *** [sslsqueeze] Error 1
After some research I tried the following commands ALL to the same result :
make -levent_core
gcc -levent_core sslsqueeze.c -o take6
gcc -L/usr/lib/x86_64-linux-gnu sslsqueeze.c -o take8
The following were also not successful. They gave "file not found" errors.
gcc -L/usr/lib/x86_64-linux-gnu -libevent_core.so sslsqueeze.c -o take7
gcc -L/usr/lib/x86_64-linux-gnu -libevent_core.a sslsqueeze.c -o take7
Final piece of information.
Header files are in /usr/include/event2
libevent_core files are in /usr/lib/x86_64-linux-gnu/(2 files, one with .so extension and the other with .a)
Any help would be appreciated!

Installing AODV protocol on Raspberry pi (https://github.com/erimatnor/aodv-uu)

I'm trying to install AODV protocol on Raspberry pi. After completing git clone from "https://github.com/erimatnor/aodv-uu" when I tried to do "make" and I am getting below error. Expecting your suggestion. Thank you!
make
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY -DDEBUG -o aodvd main.o list.o debug.o timer_queue.o aodv_socket.o aodv_hello.o aodv_neighbor.o aodv_timeout.o routing_table.o seek_list.o aodv_rreq.o aodv_rrep.o aodv_rerr.o nl.o locality.o
aodv_neighbor.o: In function neighbor_add':
/home/pi/aodv-uu/aodv_neighbor.c:68: undefined reference tohello_update_timeout'
aodv_timeout.o: In function route_discovery_timeout':
/home/pi/aodv-uu/aodv_timeout.c:98: undefined reference tort_table_update_timeout'
aodv_rreq.o: In function rreq_route_discovery':
/home/pi/aodv-uu/aodv_rreq.c:460: undefined reference tort_table_update_timeout'
aodv_rreq.o: In function rreq_local_repair':
/home/pi/aodv-uu/aodv_rreq.c:521: undefined reference tort_table_update_timeout'
aodv_rrep.o: In function rrep_forward':
/home/pi/aodv-uu/aodv_rrep.c:231: undefined reference tort_table_update_timeout'
nl.o: In function nl_kaodv_callback':
/home/pi/aodv-uu/nl.c:282: undefined reference tort_table_update_timeout'
collect2: error: ld returned 1 exit status
Makefile:112: recipe for target 'aodvd' failed
make: *** [aodvd] Error 1
The code available from sourceforge is the same code that is on github. If you download the archive, you'll see that the latest modification date of any file there is 2010. Given the age of this code, I wouldn't be surprised to find that things simply don't work anymore.
However, here's a quick workaround for your problem. The root cause appears to be that the problem functions, like rt_table_update_timeout, are declared as inline, but that information seems to get lost somewhere in the build process such that other object files are trying to reference these as non-inline functions.
You can avoid this by opening defs.h, looking for this line:
#define NS_INLINE inline
And replace it with:
#define NS_INLINE
This will allow aodvd to compile correctly (make aodvd). On my system, the kernel module will subsequently fail to compile:
cc1: fatal error: /lib/modules/4.13.15-100.fc25.x86_64/build/include/linux/modversions.h: No such file or directory
As far as I can tell, the modversions.h file is no longer produced by modern Linux kernels.

Undefined references everywhere, while trying to compile BluezTools?

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.

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.

undefined reference to #include <iconv.h>,`libiconv_open',`libiconv',`libiconv_close'

I had a problem with adding reference in my C application. I am unable to add linker reference to "libiconv" in my data compresser project.I have download "libiconv" library but confuse in adding reference which show error in compiling.I'm using Dev C++ for developing my compression apps.
here is the compile log:
Building Makefile: "C:\Dev-Cpp\Examples\eottest\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Examples\eottest\Makefile.win" all
gcc.exe eot.o libeot.o properties.o -o "Project1.exe" -L"C:/Dev-Cpp/lib"
libeot.o(.text+0x19):libeot.c: undefined reference to `libiconv_open'
libeot.o(.text+0x36):libeot.c: undefined reference to `libiconv_close'
libeot.o(.text+0x67):libeot.c: undefined reference to `libiconv'
collect2: ld returned 1 exit status`
You're only specifying an additional library path, not the actual library to link to. Try:
gcc.exe eot.o libeot.o properties.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" -liconv

Resources