why am i getting an elfclass64 error?
   
    Al Kelley
     
    blufox@ucsc.edu
       
    Sun, 08 Jun 2003 00:42:08 -0700
    
    
  
i understand how to make gmp work, but only on a
win 2000 machine under cygwin where i use
it and like it very much.
however, on the following machine
    SunOS unix1 5.8 Generic_108528-19 sun4u sparc SUNW,Ultra-80
i have failed to get gmp to work on all the versions of gcc
that i have tried:
    gcc 2.95.3
    gcc 3.2
    gcc 3.3
when i install one of the above compilers,
i then reinstall gmp-4.1.2 starting with
     ./configure --enable-cxx --prefix=$gnu
all the installations work fine.
to test gmp, i compile the factorial
program that is found at the end
of this message.  the program
compiles but fails to link
due to elfclass64 errors.
can anyone tell me what i am doing wrong?
here is what happens when i give
the command make [[i have put
in some ...'s to make it
more readable]]:
    % make
    g++  -Wall  -I/.../gnu/include  -c  main.c
    linking ...
    ld: fatal: file .../gnu/lib/libgmpxx.so: wrong ELF class: ELFCLASS64
    ld: fatal: file .../gnu/lib/libgmp.so: wrong ELF class: ELFCLASS64
    ld: fatal: File processing errors. No output written to a.out
    collect2: ld returned 1 exit status
    make: *** [a.out] Error 1
can someone tell me what i am doing wrong?
---
here is what is in the file main.c:
    #include <cassert>
    #include <iostream>
    #include <gmpxx.h>                    // for big integers
    using namespace std;
    typedef   mpz_class    zz_t;              // Z = integers
    zz_t   factorial(int n);
    int main()
    {
       int   n;
       cout << "---\n"
               "Factorial n will be computed.\n"
               "\n";
       for ( ; ; ) {
          cout << "Input n: ";
          cin >> n;
          if (!cin || n < 0)
             break;
          cout << "\n"
                  "factorial(" << n << ") = " << factorial(n) << "\n"
                  "\n";
       }
       cout << "\nBye!\n\n";
    }
    zz_t factorial(int n)
    {
       int    i;
       zz_t   product;
       assert(n >= 0);
       if (n == 0 || n == 1)
          return 1;
       product = 1;
       for (i = 2; i <= n; ++i)
          product *= i;
       return product;
    }
---
here is the makefile:
    CC      =  g++
    CFLAGS  =  -Wall
    EXEC    =  a.out
    INCLS   =  -I$(GNU)/include
    LIBS    =  -L$(GNU)/lib -lgmpxx -lgmp
    OBJS    =  main.o
    $(EXEC): $(OBJS)
            @echo "linking ..."
            @$(CC)  $(CFLAGS)  -o $(EXEC)  $(OBJS)  $(LIBS)
    %.o: %.c
            $(CC)  $(CFLAGS)  $(INCLS)  -c  $<
    clean:
            rm -f a.out *.exe *~ *.o *.obj *.tds *.stackdump
    very_clean:
            rm -f a.out a.exe *~ *.o *.stackdump $(EXEC).exe
    relink:
            @echo "relinking ..."
            @$(CC)  $(CFLAGS)  -o $(EXEC)  $(OBJS)  $(LIBS)