makbuildroot.mk script and TARGET_ARCH

2010-04-19
2013-06-06
  • Steven Zalek

    Steven Zalek - 2010-04-19

    I had a good experience utilizing your makebuildroot.mk script (here: http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64/experimental/buildsystem/makebuildroot.mk?view=log ) to download and build the mingw cross compiler on x64-bit Ubuntu 9.10.

    However, it was a small challenge to properly identify the TARGET_ARCH value to achieve the build I wanted (TARGET_ARCH=i686-w32-mingw32 works for building win32 apps for use on Windows and Wine). Some websites I went to seemed to indicate that TARGET_ARCH=i686-pc-mingw32 would work, but it did not. I was not able to run applications either on Windows7-64bit or Wine-32bit that were built with TARGET_ARCH=x86_64-w32-mingw32; I'm not sure why.

    I am interested in building the multilib version of the cross compiler with the capability to create either 32-bit or 64-bit compiled applications for either a 32-bit or 64-bit target system. Would you please provide the current TARGET_ARCH flags that should be used to create this MinGW build with the makebuildroot.mk script? Also please include what flags should be set during compile-time so that the proper binaries are created (32- or 64-bit).

    Thanks.

     
  • NightStrike

    NightStrike - 2010-04-19

    The vendor id for all of our toolchains should be -w64- , even on 32-bit builds.  "w64" just signifies this sourceforge project, not any bit-width of the resulting compiler.  I know, it's confusing.  Sorry.  I tried to fight it :P

     
  • Mook

    Mook - 2010-04-20

    Hi,

    Thanks for trying things out!  Unfortunately, I haven't attempted multilib builds in a while, so some of this information may be wrong - my memory isn't the greatest.  Sorry about that.

    For multilib builds, you need to pass various configure options down to the various components (binutils, gcc, crt).  This means setting various things instead of using the defaults provided in the configurable variables section.  I believe you would want something like:

    BINUTILS_CONFIG_EXTRA_ARGS="-enable-multilib -enable-targets=x86_64-w64-mingw32,i686-w64-mingw32" GCC_CONFIG_EXTRA_ARGS="-enable-fully-dynamic-string -enable-multilib" MINGW_CONFIG_EXTRA_ARGS="-enable-lib32 -enable-lib64" make -f makebuildroot.mk

    Of course, you'll also need to pass in TARGET_ARCH as the default architecture to build binaries for.  That is, if you use x86_64 here, -m64 is implied if none is given, otherwise use i686 and -m32 is the default instead.  You probably want to keep all this in a shell script since it's pretty ridiculously long ;)

    On using the toolchain, running gcc/g++ with -m32 (for i686) or -m64 (for x86_64) should work; for example,

    x86_64-w64-mingw32-gcc -o test.exe -m64 test.c
    

    will produce a 64 bit binary.  (From the name of the executable, though, you'd be able to tell that -m64 is default in this case anyway.)

    Good luck, and feel free to attach build logs of various thing that don't work to see if it rejiggers my memory ;)  I'll monitor the thread for changes.

    • Mook
     
  • William Henderson

    This was the perfect question and answer for my needs !!! :)

    I maintain a small distribution called tjtag, for debricking routers. I currently supply 4 builds, Linux x32/x64 and WindowsXP 32bit / Windows 7 x32/x64. Yesterday, using the information from this thread I built the multilib X64_86 host cross-compiler.
    Using CodeBlocks for my IDE, its now possible for me to build all these on linux, making my life much easier.

    @mookmoz - your information was right-on

    Thank you Developers !!

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks