Building GCC cross compiler (from “Linux” to “Windows”)

前端 未结 3 2016
野性不改
野性不改 2020-12-14 13:06

I want to build \"gcc cross-compiler\" to compile \"c/c++\" applications on \"Linux\" environment but for \"Windows\" target.

I have made this so far:

相关标签:
3条回答
  • 2020-12-14 13:20

    There are precompiled cross-compilers of MinGW-w64 available. This allows to compile native 32- and 64-bit Windows binaries from Linux, a two minute tutorial is available at http://www.blogcompiler.com/2010/07/11/compile-for-windows-on-linux/

    Just in case you don't want to spend a lot of time trying to build it yourself.

    0 讨论(0)
  • 2020-12-14 13:26

    That's actually OK: the way things go, you need to

    1. build binutils
    2. install headers
    3. build the a partial C compiler: enough to create object files, but not enough to link
    4. build the win32api and mingw runtime (which includes your missing dllcrt2.o)
    5. build a complete C compiler (and other front-ends, such as C++, Fortran, Ada, whatever, if you want them)

    You have successful performed step 3 above; it fails building libgcc (which is a GCC support library), but that means the C compiler core is functionnal (although it won't be able to link, it can still create valid object files). You can check that by looking at the gcc/xgcc file in your GCC build directory.

    So, you need to go to the next step, not worrying about your current failure.

    (To actuall install the partial C compiler, you should run make with the -k option, to have it do it best, even in the face of errors. For example, use make -k install.)

    0 讨论(0)
  • 2020-12-14 13:32

    I grepped through the MinGW sources, and found that dllcrt2.o is something built off the mingwrt package. I assume you have to compile and install that, not just copy the headers?

    0 讨论(0)
提交回复
热议问题