Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to cross compile for linux x86 with linux amd64, cmake and g++?
    primarykey
    data
    text
    <p>+1 for each piece of information that helps to complete the whole picture. You don't need to know the whole answer. I'll appreciate individual pieces of the puzzle just as much. Thanks.</p> <p>I am about to attempt my first cross-compilation. I have searched both SO and the web and found many pieces of information, but I don't always know how to put those pieces together because there are still some missing pieces.</p> <p>My host: linux Kubuntu amd64.<br> Target: linux kubuntu x86 (32bit) (should be easy, no?)<br> Tools: g++ and cmake.</p> <h1>Here is the information I found:</h1> <p><a href="https://stackoverflow.com/questions/1272357/how-to-compile-a-32-bit-binary-on-a-64-bit-linux-machine-with-gcc-cmake">How to compile a 32-bit binary on a 64-bit linux machine with gcc/cmake</a><br> mentions export CFLAGS=-m32. That's one piece.</p> <p><a href="https://stackoverflow.com/questions/1577172/cross-platform-selecting-data-types-to-use-32-64-bit">Cross-platform: selecting data types to use 32/64 bit</a><br> mentions data types. I may have to pay attention to that within my code.</p> <p><a href="https://stackoverflow.com/questions/735647/ifdef-for-32-bit-platform">#ifdef for 32-bit platform</a><br> #ifdef for 32-bit platform<br> links to the following, although I am not too sure yet how to use it:<br> <a href="http://predef.sourceforge.net/prearch.html" rel="nofollow noreferrer">http://predef.sourceforge.net/prearch.html</a></p> <p><a href="http://ww.ubuntuforums.org/showthread.php?t=1377396" rel="nofollow noreferrer">http://ww.ubuntuforums.org/showthread.php?t=1377396</a><br> I did: sudo apt-get install g++-multilib </p> <h1>missing pieces:</h1> <p>Ideally, when I do 'make' (with cmake), it should spit out both a amd64 binary and a x86 one.</p> <p>Part of my CMakeLists.txt looks like this:</p> <pre><code>add_definitions(-Wall -pthread) add_executable (../run.amd64 user.cpp time.cpp init.cpp utils.cpp main.cpp) target_link_libraries(../run.amd64 cppcms dbixx config++ ctemplate) </code></pre> <p>How do I introduce the flag -m32 to create a second executable? </p> <p>Should I want to make only one executable (e.g. for testing and debugging), how do I tell cmake to make either one or both binaries?</p> <p>Also, you can see that I use some third party libraries, some of which I had to compile myself. Does this mean that I need to compile each of those binaries for the target host as well? Some use cmake and some use: ./configure; make;<br> How would I do about compiling those libraries for the target host (flags to use, etc.)?</p> <p>Note: the dynamically linked libraries are already compiled and installed on the target computer, so maybe I don't need to worry about this step... I am not sure: this is one of my missing pieces...</p> <p>What I need is a kind of tutorial, or at least some of the missing pieces. I'll update this post with more details on what I achieved and how. </p> <p>Thanks.</p> <p>P.S.</p> <h1>Is it possible at all?</h1> <p>Searching more, I found this:<br> <a href="http://www.mail-archive.com/cmake@cmake.org/msg26265.html" rel="nofollow noreferrer">http://www.mail-archive.com/cmake@cmake.org/msg26265.html</a><br> "The original design doesn't seem to be designed for anything more than windows-linux or linux-windows cross compiles."<br> cmake is NOT tested for linux amd64 to linux x86. </p> <p><a href="http://www.cmake.org/Wiki/CMake_Cross_Compiling#FAQ.2FPotential_Problems" rel="nofollow noreferrer">http://www.cmake.org/Wiki/CMake_Cross_Compiling#FAQ.2FPotential_Problems</a><br> "On mixed 32/64 bit Linux installations cross compilation cannot be used to build for 32/64 bit only." </p> <p>??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload