Howto port autoconf based application to RTEMS.

Ralf Corsepius ralf.corsepius at
Thu Jan 13 00:56:26 UTC 2005

On Wed, 2005-01-12 at 23:10 +0100, Karel Gardas wrote: 
> Hello,
> I'm thinking about porting MICO ( to RTEMS. It uses
> autoconf based configure script, for which I need to find out the right
> combination of various *FLAGS *LIBS environment variables to get
> configure's generated simple files compiled. I'm most confused by RTEMS
> application linking... Is there any howto targeting this task?
No, there isn't any, because there exist many broken configure scripts
which do not consider cross compilation rsp. violate autoconf's working-

In general, you need to examine each configure script individually and
to check for what it is doing. However, from what I see below you
already basically seem to have understood the working principles.

As far as linking is concerned, you are on the right track ...

Theoretically, it should work "out of the box", if gcc is provided the
correct flags.

> Example: test for gethostname looks:
> ----->start<-------------
> #include "confdefs.h"
> /* System header to define __stub macros and hopefully few prototypes,
>     which can conflict with char gethostname(); below.  */
> #include <assert.h>
> /* Override any gcc2 internal prototype to avoid an error.  */
> #ifdef __cplusplus
> extern "C"
> #endif
> /* We use char because int might match the return type of a gcc2
>     builtin and then its argument prototype would still apply.  */
> char gethostname();
> int main() {
> /* The GNU C library defines this for functions which it implements
>     to always fail with ENOSYS.  Some functions are actually named
>     something starting with __ and the normal name is an alias.  */
> #if defined (__stub_gethostname) || defined (__stub___gethostname)
> choke me
> #else
> gethostname();
> #endif
> ; return 0; }
> ------>end<--------------
> and it is compiled with (those parameters are already hacked by me into
> the configure):
> configure:7258: i386-rtems-c++ -o conftest -O2
> -B/mnt/karel/rtems-x86/i386-rtems/pc386//lib -specs bsp_specs -qrtems
> -B/mnt/karel/rtems-x86/i386-rtems/pc386/lib/ -Wl,-Ttext,0x00100000
> /mnt/karel/rtems-x86/i386-rtems/pc386/lib/no-dpmem.rel
> /mnt/karel/rtems-x86/i386-rtems/pc386/lib/no-msg.rel
> /mnt/karel/rtems-x86/i386-rtems/pc386/lib/no-mp.rel
> /mnt/karel/rtems-x86/i386-rtems/pc386/lib/no-part.rel
>  /mnt/karel/rtems-x86/i386-rtems/pc386/lib/no-signal.rel
> /mnt/karel/rtems-x86/i386-rtems/pc386/lib/no-timer.rel
> /mnt/karel/rtems-x86/i386-rtems/pc386/lib/no-rtmon.rel conftest.C -lm  1>&5
> which results in undefined references:
> /mnt/karel/rtems-x86/i386-rtems/pc386//lib/librtemscpu.a(rtems_glue.o): In
> function `rtems_bsdnet_initialize_network':
> /mnt/karel/downloads/RTEMS/build/tools/obj-rtems/i386-rtems/c/pc386/exec/libnetworking/../../../../../../rtems/cpukit/libnetworking/r
> tems/rtems_glue.c:944: undefined reference to `rtems_bsdnet_config'
> /mnt/karel/downloads/RTEMS/build/tools/obj-rtems/i386-rtems/c/pc386/exec/libnetworking/../../../../../../rtems/cpukit/libnetworking/r
> tems/rtems_glue.c:953: undefined reference to `rtems_bsdnet_config'
> /mnt/karel/rtems-x86/i386-rtems/pc386//lib/librtemscpu.a(rtems_glue.o): In
> function `rtems_bsdnet_initialize':
> /mnt/karel/downloads/RTEMS/build/tools/obj-rtems/i386-rtems/c/pc386/exec/libnetworking/../../../../../../rtems/cpukit/libnetworking/r
> tems/rtems_glue.c:226: undefined reference to `rtems_bsdnet_config'
> /mnt/karel/downloads/RTEMS/build/tools/obj-rtems/i386-rtems/c/pc386/exec/libnetworking/../../../../../../rtems/cpukit/libnetworking/r
> tems/rtems_glue.c:234: undefined reference to `rtems_bsdnet_config'
> /mnt/karel/downloads/RTEMS/build/tools/obj-rtems/i386-rtems/c/pc386/exec/libnetworking/../../../../../../rtems/cpukit/libnetworking/r
> tems/rtems_glue.c:236: undefined reference to `rtems_bsdnet_config'
> /mnt/karel/rtems-x86/i386-rtems/pc386//lib/librtemscpu.a(rtems_glue.o):/mnt/karel/downloads/RTEMS/build/tools/obj-rtems/i386-rtems/c/
> pc386/exec/libnetworking/../../../../../../rtems/cpukit/libnetworking/rtems/rtems_glue.c:813:
> more undefined references to `rtems_bsdnet_config' follow

... AFAIS this is a bug in this BSP: it seems to lack
rtems_bsdnet_config, rsp. (a matter of personal perspective) a general
design bug/issue in RTEMS with networking enabled.

Please file a PR on "rtems_bsdnet" to RTEMS GNATS.


More information about the users mailing list