AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  Problems running c compiler

    Posted Fri September 04, 2009 06:23 AM

    Originally posted by: SystemAdmin


    Wondering if anyone can help me. Have recently upgraded AIX to v5.3tl09, but we are now having problems with the c compiler. Upgraded this to v9 but also have v6 running on some machine, all give the same results.

    Trying to compile the following test program:

    #include <stdio.h>
    #include <math.h>

    int main(char **args)

    {
    double f = floor(20/6);
    printf("Hello world, 20/6 ~= %2.1f\n",f);
    }

    However when I run the following command I get these results:

    1. cc -bnoquiet adv_hello_world.c -o adv_hello_world
    (ld): halt 4
    (ld): setfflag 4
    (ld): savename adv_hello_world
    (ld): filelist 5 1
    (ld): i /lib/crt0.o
    (ld): i adv_hello_world.o
    (ld): lib /usr/vac/lib/libxlopt.a
    (ld): lib /usr/vac/lib/libxl.a
    (ld): lib /usr/lib/libc.a
    LIBRARY: Shared object libc.ahttp://shr.o: 2874 symbols imported.
    LIBRARY: Shared object libc.ahttp://meth.o: 2 symbols imported.
    LIBRARY: Shared object libc.ahttp://posix_aio.o: 20 symbols imported.
    LIBRARY: Shared object libc.ahttp://aio.o: 18 symbols imported.
    LIBRARY: Shared object libc.ahttp://pse.o: 5 symbols imported.
    LIBRARY: Shared object libc.ahttp://dl.o: 4 symbols imported.
    LIBRARY: Shared object libc.ahttp://pty.o: 1 symbols imported.
    FILELIST: Number of previously inserted files processed: 5
    (ld): resolve
    RESOLVE: 38 of 6027 symbols were kept.
    (ld): addgl /usr/lib/glink.o
    ADDGL: Glink code added for 4 symbols.
    (ld): er full
    ld: 0711-318 ERROR: Undefined symbols were found.
    The following symbols are in error:
    Symbol Inpndx TY CL Source-File(Object-File) OR Import-File{Shared-object}
    RLD: Address Section Rld-type Referencing Symbol

    .floor 28 ER PR adv_hello_world.c(adv_hello_world.o)
    00000024 .text R_RBR 12 .main
    ER: The return code is 8.
    I'm hoping that someone can shed some light on it for me.

    Cheers
    Russell
    #AIX-Forum


  • 2.  Re: Problems running c compiler

    Posted Fri September 04, 2009 09:19 AM

    Originally posted by: flodstrom


    I don't have access to the xlc right now, but it looks like you are missing the math lib?

    Try...

    cc -bnoquiet adv_hello_world.c -o adv_hello_world -lm
    #AIX-Forum


  • 3.  Re: Problems running c compiler

    Posted Fri September 04, 2009 09:36 AM

    Originally posted by: SystemAdmin


    Results:
    #cc -bnoquiet adv_hello_world.c -o adv_hello_world -lm
    (ld): halt 4
    (ld): setfflag 4
    (ld): savename adv_hello_world
    (ld): filelist 6 1
    (ld): i /lib/crt0.o
    (ld): i adv_hello_world.o
    (ld): lib /usr/lib/libm.a
    (ld): lib /usr/vac/lib/libxlopt.a
    (ld): lib /usr/vac/lib/libxl.a
    (ld): lib /usr/lib/libc.a
    LIBRARY: Shared object libc.ahttp://shr.o: 2870 symbols imported.
    LIBRARY: Shared object libc.ahttp://meth.o: 2 symbols imported.
    LIBRARY: Shared object libc.ahttp://posix_aio.o: 20 symbols imported.
    LIBRARY: Shared object libc.ahttp://aio.o: 18 symbols imported.
    LIBRARY: Shared object libc.ahttp://pse.o: 5 symbols imported.
    LIBRARY: Shared object libc.ahttp://dl.o: 4 symbols imported.
    LIBRARY: Shared object libc.ahttp://pty.o: 1 symbols imported.
    FILELIST: Number of previously inserted files processed: 6
    (ld): resolve
    RESOLVE: 71 of 7235 symbols were kept.
    (ld): addgl /usr/lib/glink.o
    ADDGL: Glink code added for 15 symbols.
    (ld): er full
    ER: There are no unresolved symbols.
    (ld): mismatch
    MISMATCH: No type mismatches exist.
    (ld): comprld
    COMPRLD: Kept 111 of 111 relocation entries.
    (ld): origin page 0x10000000 0x20000000
    (ld): libpath /usr/vac/lib:/usr/lib:/lib
    LIBPATH: Library path set to /usr/vac/lib:/usr/lib:/lib
    (ld): save 1L .
    SAVE: Section sizes = 3464+528+4 (0xD88+0x210+0x4 hex)
    SAVE: Size of TOC: 144 (0x90 hex)
    (ld): rc
    RC: Highest return code was 0.
    #AIX-Forum


  • 4.  Re: Problems running c compiler

    Posted Fri September 04, 2009 11:30 AM

    Originally posted by: flodstrom


    ...so did it generate a binary for you? I don't see any error's in the output example.
    #AIX-Forum


  • 5.  Re: Problems running c compiler

    Posted Fri September 04, 2009 05:46 PM

    Originally posted by: shargus


    Your C program is doing floating-point math, yet your original cc statement does not include the "-lm", so the list of libraries included does not include /usr/lib/libm. That is probably the source of the unresolved symbols.

    The second time you ran cc, the "-lm" was on the end of the line. That instructed the C compiler to include the math library (/usr/lib/libm), which appears to be what the compiler needed.
    #AIX-Forum