Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

  • Comments
  • How to compile 32bit code

    Posted on

    I am using RHEL 7.0

    I have downloaded latest version of Eclipse cdt.

    I try to compile some 32bit c++ code.
    I have installed the "*-devel.i686"-packets

    I have set "-m32" at the compiler options and set -melf_i386

    During linking build system tries to link against libraries at /usr/lib/gcc/x86_64-redhat-linux

    I have tried to set the variables "LD_LIBRARY_PATH" and "LIBRARY_PATH" under "envirement" both to "/usr/lib" without any effect

    I have added "-L/usr/lib" and "-L/lib" to the linker.
    Now I still have a problem with crtl.o, crti.o, crtbegin.o, crtend.o and crtn.o
    I see that eclipse try to link against versions in "/lib/../lib64"

    Is there any other general way to set the libraries to 32bit?
    Do I have to install any additional packets?

    I was able to reproduce the same behaviour under command line:

    dirk1.o and dirk2.o are compiled with "-m32"

    g++ -Xlinker -melf_i386 -Xlinker -L/usr/lib -Xlinker -L/lib -Xlinker -L/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32 -L/usr/lib -L/lib dirk1.o dirk2.o -o dirk -L/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32

    /bin/ld: i386:x86-64 architecture of input file

    /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crt1.o' is incompatible with i386 output
    /bin/ld: i386:x86-64 architecture of input file
    /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crti.o' is incompatible with i386 output
    /bin/ld: i386:x86-64 architecture of input file
    /usr/lib/gcc/x86_64-redhat-linux/4.8.2/crtbegin.o' is incompatible with i386 output
    /bin/ld: i386:x86-64 architecture of input file
    /usr/lib/gcc/x86_64-redhat-linux/4.8.2/crtend.o' is incompatible with i386 output
    /bin/ld: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crtn.o' is incompatible with i386 output
    /bin/ld: /usr/lib/gcc/x86_64-redhat-linux/4.8.2/../../../../lib64/crt1.o: file class ELFCLASS64 incompatible with ELFCLASS32
    /bin/ld: final link failed: File in wrong format
    collect2: Fehler: ld gab 1 als Ende-Status zurück

    Any ideas are welcome.

    Dirk

    by

    points

    Responses

    Red Hat LinkedIn YouTube Facebook X, formerly Twitter

    Quick Links

    Help

    Site Info

    Related Sites

    © 2026 Red Hat