Compile program for 32bit on 64bit Linux OS causes fatal error

后端 未结 4 1767
长发绾君心
长发绾君心 2020-12-04 23:37

Using

gcc -m32 myprog.c

should compile in 32 bit version the file myprog.c.

Unfortunately I get this error:



        
相关标签:
4条回答
  • 2020-12-05 00:17

    You need gcc multilib support. Install the package gcc-multilib. E.g.:

    sudo apt-get install gcc-multilib
    
    0 讨论(0)
  • 2020-12-05 00:18

    I encountered to this same problem. when I was trying to build 32 bit so file while i'm in 64 bit ubuntu version.

    you can build by switching your lib version into 64 bit in netbeans (-> project properties -> C compiler -> additional options) set to

    -shared -m64
    
    0 讨论(0)
  • 2020-12-05 00:34

    To compile 32 bit binaries on 64 bit Linux version, you have to Install libx32gcc development package and 32 bit GNU C Library

    try this

    sudo apt-get install libx32gcc-4.8-dev
    

    and

    sudo apt-get install libc6-dev-i386
    
    0 讨论(0)
  • 2020-12-05 00:36

    To fix the issue we first need to know which package will provide the file sys/cdefs.h

    In CentOs/RHEL based system you can find it by running below command

    yum provides '*sys/cdefs.h'
    

    Similarly, in Debian/Ubuntu systems you can find it by running

    apt-file search 'sys/cdefs.h'
    

    Note: If apt-file package is not already present on the system install it with command

    apt-get install apt-file
    

    Both above commands will scan the respective package management systems database i.e RPM/Apt and tells the name of the package which supplies the file ending with "sys/cdefs.h".

    Install the appropriate package from the packages listed by the commands.
    Like

    On CentOs/RHEL:

    yum install glibc-headers 
    

    On Debian/Ubuntu

    apt-get install libc6-dev
    

    This approach is not only useful for this particular issue but any similar issue which is reporting some required file being provided by some package being not present.

    0 讨论(0)
提交回复
热议问题