[Xenomai] Build simple application with Xenomai 3.x

Ran Shalit ranshalit at gmail.com
Mon Feb 6 11:02:18 CET 2017

I have installed xenomai 3.3 with kernel 4.1 ,ubuntu 14.04  and it all
seems to work very well, resulting in good performace ~20u  ,tested
with cyclictest and latency. (I just has some issue with install,
"debuild -uc -us" , seems not to created /usr/xenomai/demo, so I
installed again  with "make install")

Now, I then tried to build a very simlpe application.
Is there a simple code sample with Makefile for xenomai 3 demonstration ?

I did find the following link with example:

So I tried it but it gives errors:
1. it first gave the following errors:
"...fatal error: native/task.h: No such file or directory"
so I changed from:
#include <native/task.h>
#include <trank/native/task.h>
Is it correct ? Or should I use  <alchemy/task.h> instead ?
2. I also had to remove <trank/native/intr.h> bevause there is no such file.
3. Then I got link errors:

user at user-desktop:~/rt/xen/myapp$ make
gcc -o test test.c -I/usr/xenomai/include/mercury
-I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -D__MERCURY__
-I/usr/xenomai/include/vxworks -lvxworks  -lcopperplate
/usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main
-Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib
-lmercury -lpthread -lrt
/tmp/cc3dm9ne.o: In function `testtask':
test.c:(.text+0x1e): undefined reference to `rt_timer_ns2ticks'
test.c:(.text+0x30): undefined reference to `rt_task_set_periodic'
test.c:(.text+0x5d): undefined reference to `rt_task_wait_period'
/tmp/cc3dm9ne.o: In function `clean_exit':
test.c:(.text+0xd3): undefined reference to `rt_task_delete'
/tmp/cc3dm9ne.o: In function `main':
test.c:(.text+0x14d): undefined reference to `rt_task_spawn'
collect2: error: ld returned 1 exit status
make: *** [test] Error 1
user at user-desktop:~/rt/xen/myapp$

The make options seems to include the required library , so I am not
sure why I get these link errors.

This is the makefile:
XENO_CONFIG := /usr/xenomai/bin/xeno-config
CFLAGS := $(shell $(XENO_CONFIG) --vxworks --cflags)
LDFLAGS := $(shell $(XENO_CONFIG) --vxworks --ldflags)
CC := $(shell $(XENO_CONFIG) --cc)



%: %.c
    $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)


More information about the Xenomai mailing list