linkage problem under 2.6.2.1
Hi,
First I would like to sincerely thank all the people here that kindly helped me with my previous problems regarding Xenomai installation.
Now I got Xenomai 2.6.2.1 running on Ubuntu 12.04 (Linux-3.5.7) . I added "/usr/xenomai/bin:/usr/xenomai/lib:/usr/xenomai/include:/usr/local/lib" to my $PATH, and can run "xeno latency" and "xeno-test". However, when I tried to compile this toy program found at http://www.cs.ru.nl/lab/xenomai/ , I got some linage problems as follows:/tmp/ccwl2tpg.o: In function `main':
ex01.c:(.text+0x8a): undefined reference to `rt_print_auto_init'
ex01.c:(.text+0xa2): undefined reference to `rt_printf'
ex01.c:(.text+0xe3): undefined reference to `rt_task_create'
ex01.c:(.text+0xff): undefined reference to `rt_task_start'
collect2: ld returned 1 exit status
The above source code can be compiled & linked under Xenomai 2.4.3 smoothly, and I understand that the rtdk library had been moved to libxenomai, so I changed the build flags accordingly. Below is what I used to build the above toy program:
gcc -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -lnative -L/usr/xenomai/lib -lxenomai -lpthread -lrt -lxenomai ex01.c -o ex01
On my system, running "xeno-config --skin=native --cflags" gets "-I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -D__XENO__", and running "xeno-config --skin=native --ldflags" gets "-lnative -L/usr/xenomai/lib -lxenomai -lpthread -lrt". Under "/usr/xenomai/lib", I can find libnative.[a|la|so], libxenomai.[a|la|so], and other libs.
I don't understand why there are still undefined reference to `rt_print_auto_init', etc. Did I miss something while building this program?
With many thanks,
Tom
Quoted 1 line · Tom Z
Hi,
Hi,
Quoted 3 lines
gcc -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -lnative -L/usr/xenomai/lib -lxenomai -lpthread -lrt -lxenomai
ex01.c-o ex01
The link order seems wrong.
Signature · 1 line
Gilles.
Hi Gilles,
Thanks for your answer. You're right, the order was wrong. After a few trial&error, I changed to the following order, everything seems work well. CFLAGS=$(shell $(XENOCONFIG) --skin=native --cflags)
LDFLAGS=$(shell $(XENOCONFIG) --skin=native --ldflags)
gcc $(CFLAGS) main.c $(LDFLAGS) -o main
Sincerely,
Tom
Quoted 12 lines · Gilles Chanteperdrix
Quoted 1 line · Tom Z
Hi,
Hi,
Quoted 3 lines
gcc -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -lnative -L/usr/xenomai/lib -lxenomai -lpthread -lrt -lxenomai
ex01.c-o ex01The link order seems wrong.