Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22310

build 32-bit code on 64-bit linux system (kubuntu 18.04)

$
0
0

I'm looking into porting a 32-bit AIX app to linux - doing proof of concept on my 64-bit Kubuntu desktop system. I suppose I could build the app in 64-bit mode, but I'm afraid stuff might break (there are thousands of modules - it's a whole system of apps).

Anyway, I tried building a trivial app that just printf's sizeof int, short and long variables. When I build it with 'cc test/c', it works, and sizeof reports 8-bytes for the long - so it's defaulting to 64-bit mode. But when I try building it with 'cc -m32 test.c', it won't compile.

In file included from test.c:1:0:/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory #include <bits/libc-header-start.h>          ^~~~~~~~~~~~~~~~~~~~~~~~~~compilation terminated.

So /usr/include/stdio.h does contain a reference to bits/libc-header-start.h, and there's no /usr/include/bits subdirectory. But if that's the error, why doesn't the compiler complain about it when I run it without the -m32 flag? I don't see any conditional logic around the #include in stdio.h, so what magic am I missing? Is there another /usr/include tree that gets invoked with the -m32 flag?

Various posts on here address the issue of building for 32-bits on a 64-bit machine, but they're older posts and reference an older ubuntu base. In any case, they suggest making sure that the proper libraries are loaded. I've got these (and I assume if they were already there, my 32-bit build environment ought to be okay). Is there something else I'm missing?

lib32gcc-4.8-dev/bionic 4.8.5-4ubuntu8 amd64gcc-multilib/bionic-updates,bionic-security 4:7.4.0-1ubuntu2.3 amd64

Okay, I see that there's a 'bits' directory under /usr/include/x86-64-linux-gnu, but no parallel one for a non-64bit environment.

$ locate libc-header-start.h/usr/include/x86_64-linux-gnu/bits/libc-header-start.h

So what do I install to get that? I've got these installed already:

libc6-dev-i386/bionic 2.27-3ubuntu1 amd64libc6-dev-i386-amd64-cross/bionic-updates,bionic-updates 2.27-3ubuntu1cross1.1 alllibc6-dev-i386-cross/bionic-updates,bionic-updates 2.27-3ubuntu1cross1.1 alllibc6-dev-i386-x32-cross/bionic-updates,bionic-updates 2.27-3ubuntu1cross1.2 all

Viewing all articles
Browse latest Browse all 22310

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>