#53 undefined reference to `__iob'

closed-invalid
None
5
2014-08-21
2010-07-04
Frank Weber
No

A very short Program like:

#include <stdio.h>

int main(void)
{
fprintf(stdout, "Hello World\n");
return;
}

compiled with:
gcc -noixemul -m68020 HelloWorld.c -oHelloWorld

give me at linktime the follow error message:

t:ccPzLape.o(.text+0x20): undefined reference to `__iob'
collect2: ld returned 1 exit status

What's going wrong here?
I do already a search and __iob is defined in stdio.h as:

extern struct iob ** __iob;

and later used in the same file as:

/* The three standard I/O streams */
#define stdin ((FILE *)__iob[0])
#define stdout ((FILE *)__iob[1])
#define stderr ((FILE *)__iob[2])

but then i have no trace to '__iob'. :-(

Can anybody help me or give me a hint how to link
the above program with the -noixemul option?

best regards

Discussion

  • Frank Weber

    Frank Weber - 2010-07-04

    TestProgram

     
    Attachments
  • Olaf Barthel

    Olaf Barthel - 2010-08-20

    You actually have to link against clib2. If you just compile and the program with the -noixemul switch, there's no telling what it will link against, it certainly does not link against clib2 or you would not be seeing this issue. I suppose your GCC specs file may not pick clib2 as the default runtime library.

     
  • Olaf Barthel

    Olaf Barthel - 2010-08-22
    • assigned_to: nobody --> obarthel
     
  • Frank Weber

    Frank Weber - 2010-08-22

    Yes you are right. It was my (or my machines) fault.
    Seems my specs file was not the correct one.

    I don't know why and i really don't know (yet) how the specs file works.
    Now i use your specs file and it works.
    Thanks for your hint. I'll close the issue.

    But: With your specs file i can't link some programs which
    use 'mstackextend' which seems to expand to '-lstack'!?

    Could you please give me again a hint where i can find the libstack.a
    for clib2?

     
  • Frank Weber

    Frank Weber - 2010-08-22
    • status: open --> closed-invalid
     
  • Olaf Barthel

    Olaf Barthel - 2010-08-23

    I did not succeed in creating a working libstack.a, as part of clib2. The goal of clib2 was mainly to provide for ISO 'C' (1994) compatibility, and allow for my Samba port to work. The functionality provided by libstack.a would have exceeded these goals by a bit.

    The libstack.a found in libnix (https://sourceforge.net/projects/libnix/) should still work, though.

     
  • Frank Weber

    Frank Weber - 2010-08-26

    Hi Olaf

    Sorry for the late reply but i have really big problems
    to get it running. :-(
    I spend hours to get i running without success.

    I update my libnix installation but it also doesn't work.
    I get a for example if i try to link YAM the follow error:

    LD YAM.os3.debug
    /gg/lib/gcc-lib/m68k-amigaos/2.95.3/real-ld: cannot open -lstack: No such file or directory
    collect2: ld returned 1 exit status

    GCC can't find the libstack.a. So i try to copy some of the
    libstack.a from some libnix subdirs into GG:lib/ but then
    i get always (no matter which libstack.a i use) the follow error:

    LD YAM.os3.debug
    /gg/lib/libm020/libc.a(stdlib_stackextension.o)(.data+0x0): multiple definition of `__stk_limit'
    /gg/lib/libstack.a(init_stk.o)(.data+0x0): first defined here
    /gg/lib/libm020/libc.a(stdlib_stackextension.o)(.text+0xa0): multiple definition of `__stkext_f'
    /gg/lib/libstack.a(stkext.o)(.text+0x0): first defined here
    /gg/lib/libm020/libc.a(stdlib_stackextension.o)(.text+0x78): multiple definition of `__stkext'
    /gg/lib/libstack.a(stkext.o)(.text+0x6c): first defined here
    /gg/lib/libm020/libc.a(stdlib_stackextension.o)(.text+0xc8): multiple definition of `__stkrst_f'
    /gg/lib/libstack.a(stkrst_f.o)(.text+0x0): first defined here
    /gg/lib/libstack.a(stkext.o)(.text+0x1c): undefined reference to `__used_stack'
    /gg/lib/libstack.a(stkext.o)(.text+0x26): undefined reference to `__SaveSP'
    /gg/lib/libstack.a(stkext.o)(.text+0x2e): undefined reference to `__used_stack'
    /gg/lib/libstack.a(stkext.o)(.text+0x80): undefined reference to `__used_stack'
    /gg/lib/libstack.a(stkext.o)(.text+0x116): undefined reference to `__used_stack'
    /gg/lib/libstack.a(stkext.o)(.text+0x122): undefined reference to `__SaveSP'
    /gg/lib/libstack.a(stkext.o)(.text+0x144): undefined reference to `__used_stack'
    /gg/lib/libstack.a(stkrst_f.o)(.text+0xa): undefined reference to `__used_stack'
    /gg/lib/libstack.a(xcovf.o)(.text+0x16): undefined reference to `__request'
    collect2: ld returned 1 exit status

    If i remove the '%{mstackextend:-lstack}' parts from the specs file
    or add a dummy (empty) libstack.a file to GG:lib/ YAM then is linked
    but i think then the stack stuff is not working.

    It would be really great if you could get me a hint how to get it working.
    Maybe you can send me a specs file which use Clib2 and the libnix
    stack stuff?

    best regards and many thanks for your help

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks