undefined reference to 'nanosleep'

André Neves andre-c-neves at criticalsoftware.com
Wed Sep 12 14:37:05 UTC 2007


Yuck, and now i caused a split of the discussion because i got a mail
while writing.
What a terrible day for mailing lists.

On Wed, September 12, 2007 15:07, Ralf Corsepius wrote:
> On Wed, 2007-09-12 at 14:26 +0100, André Neves wrote:
>> First of all sorry for forgetting the subject.
>> Bah, not helpful. >_<
>>
>> On Wed, September 12, 2007 13:48, Ralf Corsepius wrote:
>> > On Wed, 2007-09-12 at 12:20 +0100, André Neves wrote:
>> >> Hi all.
>> >>
>> >> I cave in and admit that the system outsmarted me.
>> >> Here goes newbie question. :)
>> >> Compiling RTEMS for a LEON2 simulator in a Linux (Ubuntu 7.04)
>> machine.
>> >> autoconf 2.61, automake 1.10, gcc 4,1,2.
>> >>
>> >> I'm in the last step of the compilation described in the wiki's Quick
>> >> Start:
>> >> > cd rtems
>> >> > export PATH=/opt/rtems-4.8/bin:$PATH
>> >> > ./bootstrap
>> >> > cd ..
>> >> > mkdir b-sis
>> >> > cd b-sis
>> >> > ../rtems/configure
>> >
>> >> --target=sparc-rtems
>> >            ^^^^^^^^^^^
>> > This must match with the target you used to build your toolchain.
>> >
>> >>  --enable-rtemsbsp=sis
>> >> --enable-tests=samples --disable-posix --disable-itron
>> >> > make
>> >>
>> >> Doing 'make all'.
>> >> > (...)
>> >> > Making all in capture
>> >> > make[5]: Entering directory
>> >> `/home/ac-neves/workdir/sparc-rtems/c/leon2/testsuites/samples/capture'
>> >> > sparc-rtems-gcc -B../../../../../leon2/lib/ -specs bsp_specs
>> -qrtems
>> > ^^^^^^ ^^^^^^^^^^^^
>> >
>> > OK, so you, for reason being incomprehensible to me used
>> > --target=sparc-rtems
>>
>> The wiki Quick Start page said to use
>> --target=sparc-rtems4.8
>>
>> It was making some part of my compilation fail, and my internship tutor
>> had a look at it and said that probably dropping the "4.8" would make it
>> work.
> He is wrong.

I got my Cross-Compiler from gaisler, pre-compiled.
Maybe they used a tag without version number, and that's where the
confusion began?
My compiler name is "sparc-rtems-gcc", would it still be named the same or
would it be "sparc-rtems4.8-gcc"?
Or maybe i'm just inexperienced and confusing it all - also very likely. :-p

>
>>  So i used
>> --target=sparc-rtems
>> instead, to see if that would solve the problem.
> It doesn't. All that matters is always using an identical --target and
> the same --prefix, in all configurations, binutils, gcc+newlib and RTEMS
> itself.
>
> The official recommendation is "sparc-rtems4.8".
>
>> It did, and so i went and edited the wiki accordingly.
> Which wiki did you edit?

http://www.rtems.com/wiki/index.php/Quick_Start
I've reverted the (seemingly) improper change now, but do take a look and
revert the other two changes if they don't belong there. :)


>
>> If i did wrong, please edit it back into the correct option·
>>
>> (Low) personal experience says the right option is the one I used,
>> expert
>> says what I used makes no sense.
>> Hmm... I don't know what should be there. I know no other option. :)
>>
>> >
>> >> -mcpu=cypress -msoft-float -O2 -g      -o capture.exe init.o test1.o
>> >> > ../../../../../leon2/lib/librtemscpu.a(libposix_a-usleep.o): In
>> >> function
>> >> `usleep':
>> >> > /home/ac-neves/workdir/sparc-rtems/c/leon2/cpukit/posix/../../../../../../rtems-leon2/c/src/../../cpukit/posix/src/usleep.c:29:
>> >> undefined reference to `nanosleep'
>> >> > collect2: ld returned 1 exit status
>> >> > make[5]: *** [capture.exe] Error 1
>> >> > make[5]: Leaving directory
>> >> `/home/ac-neves/workdir/sparc-rtems/c/leon2/testsuites/samples/capture'
>> >> > (...)
>> >>
>> >> I've been trying to fix it myself, but failed to understand how
>> >> everything
>> >> is well except for nanosleep.
>> >> Can something not have been included properly?
>> > Have you build newlib?
>
>> Hmm... libnewlib-dev was missing.
> Where would this come from? There is no libnewlib-dev which would be
> relevant for RTEMS.
>
> You need to build sparc-rtems4.8-newlib when building
> sparc-rtems4.8-gcc.
>
>> (Like libc-dev was missing, and manpages-dev was missing. o_O I'm
>> starting
>> to dislike this Kubuntu.)
> Switch to fedora and you can use the pre-packaged binaries ;) [1]
>
> Ralf
>
> [1] OK, this remark wasn't quite fair, I am biased ;)
>
>
>

'lilnewlib-dev' came from the system packages - when you said newlib, i
went to 'apt-search newlib' and installed the three it found. The
'libnewlib-dev' was missing.
I had no idea you meant one inside rtems. *shrugs*

Is it possible then that the Cross-Compiler i got from gaisler doesn't
have rtems-newlib built?

How would i check if it has?
Taking into consideration that it's not an executable... i'd have to try
to compile something that requires newlib, right?
As a newbie, i have no idea of what could be such a thing.

Share a light? :)


Thanks again! :]
 Andre´ Neves

re: [1] Hmm... if biased input is the best input, biased input will have
to do. :-p





More information about the users mailing list