Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2008
    Posts
    6

    Unanswered: C prog compilation error on AIX using Gcc

    Hi,

    I am trying to compile a C prog. which I found on the internet
    using GCC compiler.

    Can anybody help me ?

    Thanks,

    I get the following error message:


    In file included from myprogram.c:20:
    /opt/IBM/db2/V9.1/include/sqladef.h:38: warning: ignoring #pragma options align
    /opt/IBM/db2/V9.1/include/sqladef.h:230: warning: ignoring #pragma options align
    In file included from myprogram.sqc:24:
    /opt/IBM/db2/V9.1/include/sqlca.h:33: warning: ignoring #pragma options align
    /opt/IBM/db2/V9.1/include/sqlca.h:116: warning: ignoring #pragma options align
    myprogram.sqc:27: warning: return type of 'main' is not 'int'
    ld: 0706-005 Cannot find or open file:
    ldpen(): A file or directory in the path name does not exist.
    collect2: ld returned 255 exit status

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    The code seems to be crappy - "main" returns "int" for decades already, but some folks still do it wrong and use "void". I would be very, very careful using it. Who knows what else is wrong?

    Besides that, you have a linker issue, not a compiler problem. There are a bunch of warnings that you can ignore. When linking everything into an executable, something is missing. You should show us the exact commands that you try to use...
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Feb 2008
    Posts
    6
    Hello there,
    After I had done my post here I realized that the main() should be returning int and not void. I have corrected that... Thanks for pointing it too..
    I have used the following command to compile it and was able to get a.out

    Thanks in advance.



    gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
    -L/database1/db2home/db2inst3/sqllib/lib \
    -ldb2

    But following command gives errors :

    gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
    -L/database1/db2home/db2inst3/sqllib/lib \
    -ldb2
    -Wl,-rpath, /opt/IBM/db2/V9.1

  4. #4
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Quote Originally Posted by UDBStudent
    But following command gives errors :
    gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
    -L/database1/db2home/db2inst3/sqllib/lib \
    -ldb2
    -Wl,-rpath, /opt/IBM/db2/V9.1
    Just leave out the rpath, and set LD_LIBRARY_PATH to /opt/IBM/db2/V9.1
    Or maybe this is not even necessary; depends on the platform.
    If I'm not mistaken this only works on Solaris, and is only needed if the db2 library is a shared lib (db2.so), not if it's a static one (db2.a).
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Quote Originally Posted by UDBStudent
    gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
    -L/database1/db2home/db2inst3/sqllib/lib \
    -ldb2

    But following command gives errors :

    gcc myprogram.c -Wall -I/opt/IBM/db2/V9.1/include \
    -L/database1/db2home/db2inst3/sqllib/lib \
    -ldb2
    -Wl,-rpath, /opt/IBM/db2/V9.1
    Do you have a space between "-Wl,-rpath," and "/opt/IBM/db2/V9.1"? If so, you should remove this. Otherwise, you are adding and empty path to the linker search path and the linker has no idea what to do with the "/opt/IBM/db2/V9.1" because it is a directory and not a file.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  6. #6
    Join Date
    Feb 2008
    Posts
    6
    Thanks a lot guys for your immense help.
    I was able to solve the problem with dropping off the
    -Wl,-rpath, /opt/IBM/db2/V9.1

    Thanks,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •