[En-Nut-Discussion] undefined references in Unix Emulation

José Vallet jose.vallet at hut.fi
Tue Jan 22 13:58:03 CET 2008


Hello.

I need to debug a "hairy" piece of code, and I was thinking about using 
the unix emulation stuff. I have some problems with the compilation of 
an example.

Is anybody using it succesfully with ethernut-4.4.0?

Here is what I do.

Using nutconf with the following configuration
Tools->GCC for Linux
Architecture->Target CPU->Linux Emulator
Edit->Settings->build->Platform->gcc
throws errors when building the libraries (that I attach at the end of 
the message, just in case)

Following http://www.ethernut.de/nutwiki/UnixEmulationInstallation takes 
me a bit further. After preparing the system for Unix emulation 
(nutsetup->5) then the errors are about no return statements, as 
explained in the nutwiki.
------------
make -C ../arch
make[1]: Entering directory `/home/jose/ethernut/ethernut-4.4.0/arch'
gcc  -c -g -Os -Wall -Werror -Wstrict-prototypes   -I../include 
unix/dev/ostimer.c -o unix/dev/ostimer.o
cc1: warnings being treated as errors
unix/dev/ostimer.c: In function ‘NutTimerEmulation’:
unix/dev/ostimer.c:82: warning: no return statement in function 
returning non-void
make[1]: *** [unix/dev/ostimer.o] Error 1
make[1]: Leaving directory `/home/jose/ethernut/ethernut-4.4.0/arch'
make: *** [all] Error 2
-------------

However, trying to solve it as suggested (adding return(NULL)) yields

-------------
make -C ../arch
make[1]: Entering directory `/home/jose/ethernut/ethernut-4.4.0/arch'
gcc  -c -g -Os -Wall -Werror -Wstrict-prototypes   -I../include 
unix/dev/ostimer.c -o unix/dev/ostimer.o
cc1: warnings being treated as errors
unix/dev/ostimer.c: In function ‘NutTimerEmulation’:
unix/dev/ostimer.c:82: warning: function declared ‘noreturn’ has a 
‘return’ statement
make[1]: *** [unix/dev/ostimer.o] Error 1
make[1]: Leaving directory `/home/jose/ethernut/ethernut-4.4.0/arch'
make: *** [all] Error 2
-------------

from where I see that somehow the declaration
void *NutTimerEmulation(void *) __attribute__ ((noreturn));
feels strange. Removing the "__attribute__ ((noreturn))" (in the 2 
places suggested) lets me go further. Then I do the "quick and dirty 
solution" (as suggested in the nutwiki) to avoid problems when compiling 
some unsupported device drivers and after I can run make and make 
install smoothly. The result of the installation are the following files 
in the lib/gcc/unix/ directory

libnutarch.a
libnutcrt.a
libnutcrtf.a
libnutdev.a
libnutfs.a
libnutnet.a
libnutos.a
libnutpro.a
nutinit.o

Then I prepare a program and modify the makefile to ensure the use of 
the appropriate library path (lib/gcc/unix). The compilation result is a 
bunch of undefined references to `pthread_create', `pthread_sigmask', 
`pthread_create', `NutGetTickClock', `NutTimerMillisToTicks' and 
`NutEventPostAsync' (details follow).

It seems that the linker does not find those, which suggests that some 
libraries are missing, right?

Any suggestions?

Regards
José

---------
Compilation of the sample application
---------
make -k all
gcc  -c  -Os -Wall -Wstrict-prototypes -Wa,-ahlms=ushell-test.lst 
-DETHERNUT2 -I/home/jose/ethernut/ethernut-4.4.0-bld/include 
-I/home/jose/ethernut/ethernut-4.4.0/include  ushell-test.c -o ushell-test.o
gcc  -c  -Os -Wall -Wstrict-prototypes -Wa,-ahlms=btn-terminal.lst 
-DETHERNUT2 -I/home/jose/ethernut/ethernut-4.4.0-bld/include 
-I/home/jose/ethernut/ethernut-4.4.0/include  btn-terminal.c -o 
btn-terminal.o
gcc  -c  -Os -Wall -Wstrict-prototypes -Wa,-ahlms=nut-cmds.lst 
-DETHERNUT2 -I/home/jose/ethernut/ethernut-4.4.0-bld/include 
-I/home/jose/ethernut/ethernut-4.4.0/include  nut-cmds.c -o nut-cmds.o
gcc  ushell-test.o btn-terminal.o nut-cmds.o 
-Wl,--defsym=main=0,-Map=ushell-test.map,--cref 
-L/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix 
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/nutinit.o -lnutarch 
-lnutnet -lnutpro -lnutfs -lnutos -lnutdev -lnutnet -lnutcrt -lm -o 
ushell-test.elf
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/nutinit.o: In function 
`NutIRQInit':
/home/jose/ethernut/ethernut-4.4.0/os/../arch/unix/os/nutinit.c:354: 
undefined reference to `pthread_create'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/nutinit.o: In function 
`NutUnixInterruptScheduler':
/home/jose/ethernut/ethernut-4.4.0/os/../arch/unix/os/nutinit.c:204: 
undefined reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/os/../arch/unix/os/nutinit.c:218: 
undefined reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/nutinit.o: In function 
`NutInterruptEmulation':
/home/jose/ethernut/ethernut-4.4.0/os/../arch/unix/os/nutinit.c:290: 
undefined reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/nutinit.o: In function 
`NutRegisterIrqHandler':
/home/jose/ethernut/ethernut-4.4.0/os/../arch/unix/os/nutinit.c:116: 
undefined reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/os/../arch/unix/os/nutinit.c:116: 
undefined reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/nutinit.o:/home/jose/ethernut/ethernut-4.4.0/os/../arch/unix/os/nutinit.c:121: 
more undefined references to `pthread_sigmask' follow
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutarch.a(unix_devs.o): 
In function `UnixDevOpen':
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/unix_devs.c:587: 
undefined reference to `pthread_create'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutarch.a(thread.o): 
In function `NutThreadSwitch':
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:148: undefined 
reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:148: undefined 
reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:167: undefined 
reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:167: undefined 
reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutarch.a(thread.o): 
In function `NutThreadCreate':
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:198: undefined 
reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutarch.a(thread.o):/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:198: 
more undefined references to `pthread_sigmask' follow
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutarch.a(thread.o): 
In function `NutThreadCreate':
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:270: undefined 
reference to `pthread_create'
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:289: undefined 
reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:289: undefined 
reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutarch.a(thread.o): 
In function `NutThreadEntry':
/home/jose/ethernut/ethernut-4.4.0/arch/unix/os/thread.c:114: undefined 
reference to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutos.a(timer.o): In 
function `NutGetMillis':
/home/jose/ethernut/ethernut-4.4.0/os/timer.c:610: undefined reference 
to `NutGetTickClock'
/home/jose/ethernut/ethernut-4.4.0/os/timer.c:611: undefined reference 
to `NutGetTickClock'
/home/jose/ethernut/ethernut-4.4.0/os/timer.c:612: undefined reference 
to `NutGetTickClock'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutos.a(timer.o): In 
function `NutGetSeconds':
/home/jose/ethernut/ethernut-4.4.0/os/timer.c:587: undefined reference 
to `NutGetTickClock'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutos.a(timer.o): In 
function `NutTimerStart':
/home/jose/ethernut/ethernut-4.4.0/os/timer.c:466: undefined reference 
to `NutTimerMillisToTicks'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutos.a(event.o): In 
function `NutEventPostAsync':
/home/jose/ethernut/ethernut-4.4.0/os/event.c:375: undefined reference 
to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/os/event.c:375: undefined reference 
to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/os/event.c:377: undefined reference 
to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/os/event.c:377: undefined reference 
to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/os/event.c:385: undefined reference 
to `pthread_sigmask'
/home/jose/ethernut/ethernut-4.4.0/lib/gcc/unix/libnutos.a(event.o):/home/jose/ethernut/ethernut-4.4.0/os/event.c:385: 
more undefined references to `pthread_sigmask' follow
collect2: ld returned 1 exit status
make: *** [ushell-test.elf] Error 1
make: Target `all' not remade because of errors.
-----------------------



------------
Build errors with nutconf
------------
07:56:20 PM: ----- Running 'make clean' -----
make[1]: *** No rule to make target `cleancc', needed by `clean'.  Stop.
make: *** [clean] Error 2
07:56:24 PM: ----- 'make clean' failed with error 2 -----
07:56:25 PM: ----- Running 'make all' -----
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:59: error: 
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘timer_thread’
cc1: warnings being treated as errors
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c: In function 
‘NutTimerEmulation’:
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:75: warning: 
implicit declaration of function ‘pthread_sigmask’
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:75: error: 
‘SIG_BLOCK’ undeclared (first use in this function)
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:75: error: 
(Each undeclared identifier is reported only once
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:75: error: 
for each function it appears in.)
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:75: error: 
‘irq_signal’ undeclared (first use in this function)
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:78: warning: 
implicit declaration of function ‘usleep’
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:80: warning: 
implicit declaration of function ‘NutUnixRaiseInterrupt’
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:82: warning: 
no return statement in function returning non-void
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c: In function 
‘NutRegisterTimer’:
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:113: error: 
‘IRQ_TIMER0’ undeclared (first use in this function)
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:116: warning: 
passing argument 1 of ‘NutRegisterIrqHandler’ makes pointer from integer 
without a cast
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:119: warning: 
implicit declaration of function ‘pthread_create’
/home/jose/ethernut/ethernut-4.4.0/arch/unix/dev/ostimer.c:119: error: 
‘timer_thread’ undeclared (first use in this function)
make[1]: *** [unix/dev/ostimer.o] Error 1
make: *** [all] Error 2
07:56:32 PM: ----- 'make all' failed with error 2 -----
07:56:34 PM: ----- Running 'make install' -----
07:56:42 PM: ----- 'make install' terminated successfully -----
--------



More information about the En-Nut-Discussion mailing list