title: compiling using gcc 32bit, as a 64 bit program with -m64
body: <p>I have 32bit gcc. Since all my third party libraries are 64 bit, and due to the project contraints, I will have to build my applications in to 64 bit in solaris.</p>
  
  <p>Hopefully I can use -m64 option with the 32bit gcc compiler to achieve this.</p>
  
  <p>But I'm not sure if this alone would suffice to successfully build.</p>
  
  <p>I repeatedly get <code>wrong ELF class: ELFCLASS64</code> errors even if I use -m64 for the 32bit compiler. I found out this is due to the mismatch of 32/64 bit libraries.</p>
  
  <p>The following are the contents of my gcc 32bit lib directory</p>
  
  <pre><code>ls -ltr /xxx/xxx/gcc/32-bit/4.4.1/lib/
  
     4096 Aug 17  2009 gcc
      894 Aug 17  2009 libsupc++.la
   574980 Aug 17  2009 libsupc++.a
  5670284 Aug 17  2009 libstdc++.so.6.0.12
      960 Aug 17  2009 libstdc++.la
  7507622 Aug 17  2009 libstdc++.a
     4096 Aug 17  2009 debug
    26504 Aug 17  2009 libssp.so.0.0.0
      933 Aug 17  2009 libssp.la
    44866 Aug 17  2009 libssp.a
      915 Aug 17  2009 libssp_nonshared.la
     2402 Aug 17  2009 libssp_nonshared.a
   228812 Aug 17  2009 libgcc_s.so.1
  3081544 Aug 17  2009 libgfortran.so.3.0.0
      972 Aug 17  2009 libgfortran.la
  4360794 Aug 17  2009 libgfortran.a
   611750 Aug 17  2009 libiberty.a
     4096 Aug 17  2009 amd64
      170 Aug 17  2009 libgomp.spec
   247908 Aug 17  2009 libgomp.so.1.0.0
      945 Aug 17  2009 libgomp.la
   333476 Aug 17  2009 libgomp.a
       13 Aug 17  2009 libgcc_s.so -&gt; libgcc_s.so.1
       20 Aug 17  2009 libgfortran.so -&gt; libgfortran.so.3.0.0
       20 Aug 17  2009 libgfortran.so.3 -&gt; libgfortran.so.3.0.0
       16 Aug 17  2009 libgomp.so -&gt; libgomp.so.1.0.0
       16 Aug 17  2009 libgomp.so.1 -&gt; libgomp.so.1.0.0
       15 Aug 17  2009 libssp.so -&gt; libssp.so.0.0.0
       15 Aug 17  2009 libssp.so.0 -&gt; libssp.so.0.0.0
       19 Aug 17  2009 libstdc++.so -&gt; libstdc++.so.6.0.12
       19 Aug 17  2009 libstdc++.so.6 -&gt; libstdc++.so.6.0.12
  </code></pre>
  
  <p>All these C++ libraries are 32 bit isnt it? do I need to find their 64 bit equivalent to succcesfully build?</p>