Thread: wrong ELF class: ELFCLASS64

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    12

    wrong ELF class: ELFCLASS64

    Hi ,

    I am trying to compile a code in various different combinations of Sun OS and Oracle versions.

    Case 1. Sun OS 5.8 Oracle pointing to 32 bit library:

    Code compiles and runs

    Case 2: Sun OS 5.10 Oracle pointing to 32 bit library:

    Code compiles and runs

    Case 3: Sun OS 5.10 Oracle pointing to 64 bit library:

    Code does not compile . Throws the following error:

    ld: warning: file /usr/Oracle/9.2.0.6/lib//libclntst9.a(sqlbuf.o): wrong ELF class: ELFCLASS64
    Undefined first referenced
    symbol in file
    sqlcxt <code1>.o
    sqlglm <code2>.o
    sqlbuft <code2>.o
    ld: fatal: Symbol referencing errors. No output written to <code1>
    collect2: ld returned 1 exit status
    *** Error code 1
    make: Fatal error: Command failed for target `build'

    I need to compile this code in the 64 bit oracle .

    Any help is highly appreciated.

    Thanks in advance,
    noviC

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It looks to me like you are not telling the linker to produce a 64-bit binary (and perhaps not compiling YOUR object code as 64-bit either, as I'd expect it to moan about that too if that was the case.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    12

    wrong ELF class: ELFCLASS64

    Thanks Mats.

    Can you please tell me how to fix this?

    I have tried compiling using the "-m64" option as well and it does not work.

    Thanks
    noviC

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    -m64 sounds like the right option. I presume you have a line listing a load of object files in your makefile (or whatever build-script you are using). That will also need -m64.

    Beyond that, I'm not quite sure, since you haven't really shown us what you are doing.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    12
    I am compiling using the following:

    /usr/local/bin/gcc -c prog1.c -o prog1 -m64

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And where is prog1.o linked to other files?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Mar 2009
    Posts
    12
    My makefile is doing the following:

    build:
    if [ "$(ORA_CLIENT_LIB)" = "shared" ]; then \
    # $(CC) -o $(EXE) $(OBJS) -L$(LIBHOME) $(PROLDLIBS); \
    $(CC) -o $(EXE) $(OBJS) -m64 $(LIBHOME) $(PROLDLIBS); \
    else \
    # $(CC) -o $(EXE) $(OBJS) -L$(LIBHOME) $(PROLLS); \
    $(CC) -o $(EXE) $(OBJS) -m64 $(LIBHOME) $(PROLLS); \
    fi

  8. #8
    Registered User
    Join Date
    Mar 2009
    Posts
    12
    Also,


    gcc -o prog1 -L /usr/orasys/9.2.0.6/lib -lclntsh -m64
    Undefined first referenced
    symbol in file
    main /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/sparcv9/crt1.o
    ld: fatal: Symbol referencing errors. No output written to prog1
    collect2: ld returned 1 exit status
    gcc -o prog1 -m64
    gcc: no input files

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by noviC View Post
    Also,


    gcc -o prog1 -L /usr/orasys/9.2.0.6/lib -lclntsh -m64
    Undefined first referenced
    symbol in file
    main /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/sparcv9/crt1.o
    ld: fatal: Symbol referencing errors. No output written to prog1
    collect2: ld returned 1 exit status
    gcc -o prog1 -m64
    gcc: no input files
    I would believe that. You set the output file to be prog1, you set the library path, you include clntsh library, you set -m64 ... but you don't have any code. It looks like your $OBJS is blank. Double check that.

  10. #10
    Registered User
    Join Date
    Mar 2009
    Posts
    12
    My OBJ file is not blank...... ...

    Is there any other way of compiling my code?

    I mean a simple command like :

    gcc -c prog1.c -o prog kind.....

  11. #11
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by tabstop View Post
    I would believe that. You set the output file to be prog1, you set the library path, you include clntsh library, you set -m64 ... but you don't have any code. It looks like your $OBJS is blank. Double check that.
    I think what is being indicated here is that this command
    Code:
    gcc -o prog1 -L /usr/orasys/9.2.0.6/lib -lclntsh -m64
    would produce a blank object (prog1) because you have not given the compiler any code to compile.

    A simple command might be
    Code:
    gcc -o prog1 prog1.c  then your flags
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  12. #12
    Registered User
    Join Date
    Mar 2009
    Posts
    12
    I have tried that as well.....

    See the out put:


    gcc -o PROG PROG1.c -L /usr/orasys/9.2.0.6/lib -lclntsh -m64
    In file included from PROG1.c:294:

    Undefined first referenced
    symbol in file
    trim /var/tmp//cc2Gv4ua.o
    FUNC1 /var/tmp//cc2Gv4ua.o
    FUNC2 /var/tmp//cc2Gv4ua.o
    FUNC3 /var/tmp//cc2Gv4ua.o
    FUNC4 /var/tmp//cc2Gv4ua.o
    FUNC5 /var/tmp//cc2Gv4ua.o
    FUNC6 /var/tmp//cc2Gv4ua.o
    ld: fatal: Symbol referencing errors. No output written to PROG1
    collect2: ld returned 1 exit status


    The functions written in my code are really simple ones....and the code compiles with a 32 bit library....

  13. #13
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    If you are compiling code that uses libraries compiled for 32-bit architecture (that's my impression) on a 64-bit machine, shouldn't that switch be -m32 (not -m64).

    Worth trying...
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  14. #14
    Registered User
    Join Date
    Mar 2009
    Posts
    12
    The code compiles fine in 32 bit library , the binary runs fine in 32 bit and 64 bit .....but I have to compile it in 64 bit as well...where am I going wrong?

  15. #15
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by noviC View Post
    I have tried that as well.....

    See the out put:


    gcc -o PROG PROG1.c -L /usr/orasys/9.2.0.6/lib -lclntsh -m64
    In file included from PROG1.c:294:

    Undefined first referenced
    symbol in file
    trim /var/tmp//cc2Gv4ua.o
    FUNC1 /var/tmp//cc2Gv4ua.o
    FUNC2 /var/tmp//cc2Gv4ua.o
    FUNC3 /var/tmp//cc2Gv4ua.o
    FUNC4 /var/tmp//cc2Gv4ua.o
    FUNC5 /var/tmp//cc2Gv4ua.o
    FUNC6 /var/tmp//cc2Gv4ua.o
    ld: fatal: Symbol referencing errors. No output written to PROG1
    collect2: ld returned 1 exit status


    The functions written in my code are really simple ones....and the code compiles with a 32 bit library....
    See, your $(OBJS) variable should have expanded to prog1.c. But it didn't.

    Where are trim and FUNC1 through FUNC6 defined? If not in your library, but another source code file, you'll need to put that file in the list too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 09:10 AM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. class member access denied
    By chiqui in forum C++ Programming
    Replies: 2
    Last Post: 05-27-2002, 02:02 PM