title: How to create a 32-bit shared-library on a 64-bit platform with autotools
body: <p>I'm using autotools to build my system, which consists primarily of a library. On 64-bit Red Hat platforms, I need to be able to produce a library capable of working on 32-bit Red Hat platforms. </p>
  
  <p>When I add <code>-m32</code> to the compile lines everything works fine to produce a static (<code>.a</code>) library, but as soon as I try to create a shared-library, I get error like this:</p>
  
  <pre><code>/usr/bin/ld: warning: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crti.o' is incompatible with i386 output
  /usr/bin/ld: warning: i386:x86-64 architecture of input file `/usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtbeginS.o' is incompatible with i386 output  
  /usr/lib/gcc/x86_64-redhat-linux/4.1.2/crtbeginS.o: In function `__do_global_dtors_aux':  
  crtstuff.c:(.text+0x29): undefined reference to `__DTOR_END__'  
  collect2: ld returned 1 exit status' 
  </code></pre>
  
  <p>I can see the problem is that it's including 64-bit object files out of /usr/lib64 instead of the correct 32-bit ones out of /usr/lib (they're there alright), but I can't figure out how to fix it.</p>