Wrong ELF class: ELFCLASS64

568 views
Skip to first unread message

Joseph Coffey

unread,
Nov 24, 2009, 11:38:13 PM11/24/09
to cython-users
Hi,

I am attempting to experiment with cython on Solaris x86 10, with a 64
bit python installation. Unfortunately, when attempting to compile
any cython program (even hello world) with pyximport I get the
following error:

In [1]: import pyximport


In [2]: pyximport.install()


In [3]: import cython_hello

ld: fatal: file /u/coffey/.pyxbld/temp.solaris-2.10-i86pc-2.6/u/
coffey/.pyxbld/temp.solaris-2.10-i86pc-2.6/pyrex/cython_hello.o: wrong
ELF class: ELFCLASS64

ld: fatal: File processing errors. No output written to /u/
coffey/.pyxbld/lib.solaris-2.10-i86pc-2.6/cython_hello.so



I guess it is probably some confusion between 64 bit and 32 bit
compilers but beyond that Iam pretty clueless. Any thoughts would be
appreciated.

Robert Bradshaw

unread,
Nov 27, 2009, 5:58:35 PM11/27/09
to cython...@googlegroups.com
I'm not sure what would cause this error--could you try compiling and
using your class with a setup.py?

- Robert

Joseph Coffey

unread,
Dec 3, 2009, 11:27:19 AM12/3/09
to cython-users
I get a similar error:

[coffey@cs1]$ python2.6 setup.py build_ext --
inplace
[11:22]
running build_ext
building 'cython_hello' extension
/proj/lang/SunOS.5.i386/gcc-4.3.3/bin/gcc -fno-strict-aliasing -
DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -O3 -m64 -g -fPIC -I/
usr/local/pkgs/python-2.6.1/include/python2.6 -c cython_hello.c -o
build/temp.solaris-2.10-i86pc-2.6/cython_hello.o
/proj/lang/SunOS.5.i386/gcc-4.3.3/bin/gcc -shared build/
temp.solaris-2.10-i86pc-2.6/cython_hello.o -lpython2.6 -o
cython_hello.so
ld: fatal: file build/temp.solaris-2.10-i86pc-2.6/cython_hello.o:
wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to
cython_hello.so
collect2: ld returned 1 exit status
error: command '/proj/lang/SunOS.5.i386/gcc-4.3.3/bin/gcc' failed with
exit status 1


On Nov 27, 5:58 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:

Joseph Coffey

unread,
Dec 3, 2009, 11:44:54 AM12/3/09
to cython-users
So my C experience is pretty limited, but when I googled for the wrong
ELF class error on Solaris (in the C context) I got the following
explanation:


From ld(1):

No command-line option is required to distinguish 32-bit
objects or 64-bit objects. The link-editor uses the ELF
class of the first relocatable object file that is found on
the command line, to govern the mode in which to operate.

So that if somehow the compiler was finding a 32 bit object and then a
64 bit object it would become confused? Does this seem likely to
occur in the cython/setup tools compilation process?

Lisandro Dalcin

unread,
Dec 3, 2009, 4:27:19 PM12/3/09
to cython...@googlegroups.com
On Thu, Dec 3, 2009 at 1:44 PM, Joseph Coffey <joe.c...@gmail.com> wrote:
> So my C experience is pretty limited, but when I googled for the wrong
> ELF class error on Solaris (in the C context) I got the following
> explanation:
>

Despite these explanations in manpages, try the lines below:

$ export LDFLAGS='-m64'
$ python setup.py build ...

If this work, that does not mean your manpage is wrong. Left as an
exercise to the reader ...
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

Joseph Coffey

unread,
Dec 4, 2009, 11:48:11 AM12/4/09
to cython-users
That seemed useful, in that it works :)

However the setup script is still a little confused. If I run

[coffey@cs1$ python2.6 setup.py build_ext --
inplace
[11:33]
running build_ext
building 'cython_hello' extension
/proj/lang/SunOS.5.i386/gcc-4.3.3/bin/gcc -shared -m64 build/
temp.solaris-2.10-i86pc-2.6/cython_hello.o -lpython2.6 -o
cython_hello.so
ld: fatal: library -lpython2.6: not found
ld: fatal: File processing errors. No output written to
cython_hello.so
collect2: ld returned 1 exit status
error: command '/proj/lang/SunOS.5.i386/gcc-4.3.3/bin/gcc' failed with
exit status 1

But now if I compile the resulting c file with:
/proj/lang/SunOS.5.i386/gcc-4.3.3/bin/gcc -shared -m64 build/
temp.solaris-2.10-i86pc-2.6/cython_hello.o -o cython_hello.so

it compiles. I can then import it and it seems to work.



On Dec 3, 4:27 pm, Lisandro Dalcin <dalc...@gmail.com> wrote:

Lisandro Dalcin

unread,
Dec 4, 2009, 1:18:03 PM12/4/09
to cython...@googlegroups.com
On Fri, Dec 4, 2009 at 1:48 PM, Joseph Coffey <joe.c...@gmail.com> wrote:
> That seemed useful, in that it works :)
>
> However the setup script is still a little confused.

It seems your Python installation is a bit broken, I think you should
open the file

/usr/local/pkgs/python-2.6.1/lib/python2.6/config/Makefile

and make sure the LDFLAGS variable has this:

LDFLAGS = -m64 -L/usr/local/pkgs/python-2.6.1/lib

In short, play with the stuff in the Makefile until you can get it working...
Reply all
Reply to author
Forward
0 new messages