构建GCC交叉编译器(从“Linux”到“Windows”) [英] Building GCC cross compiler (from "Linux" to "Windows")

查看:490
本文介绍了构建GCC交叉编译器(从“Linux”到“Windows”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立gcc交叉编译器,在Linux环境下编译c / c ++应用程序,但对于Windows目标。

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:


  1. 安装了必要的工具和软件包,用于在 GCC的先决条件页面。

来源:

gcc-core-4.4.1 gcc-g ++ - 4.4.1 binutils-2.19.1 w32api-3.13-mingw32 mingwrt-3.16-mingw32

为最终的交叉编译器创建了此目录层次结构:

$ {HOME} / gcc /
$ {HOME} / src / - 对于源

$ {HOME} / src / build-binutils / i386-mingw32 / - 用于将binutils构建为i386-mingw32目标

$ {HOME} / src / build-gcc / i386-mingw32 / - 用于将gcc构建为i386-mingw32目标

Created this directory hierarchy:
"${HOME}/gcc/" - for final cross-compiler
"${HOME}/src/" - for sources
"${HOME}/src/build-binutils/i386-mingw32/" - for building binutils to "i386-mingw32" target
"${HOME}/src/build-gcc/i386-mingw32/" - for building gcc to "i386-mingw32" target

Builded binutils package:

Builded binutils package:

cd$ {HOME} / src / build-binutils / i386-mingw32 /

.. /../binutils-2.19.1/configure --prefix =$ {HOME} / gcc--target = i386-mingw32 --disable-nls

make

make install

cd "${HOME}/src/build-binutils/i386-mingw32/"
../../binutils-2.19.1/configure --prefix="${HOME}/gcc" --target=i386-mingw32 --disable-nls
make
make install

将w32api和mingwrt标题复制到安装目录:

Copied "w32api" and "mingwrt" headers to the install directory:

cp -R$ {HOME} /src/w32api-3.13-mingw32/include$ {HOME} / gcc / i386-mingw32

cp -R$ {HOME} / src / mingwrt- 3.16-mingw32 / include$ {HOME} / gcc / i386-mingw32

cp -R "${HOME}/src/w32api-3.13-mingw32/include" "${HOME}/gcc/i386-mingw32"
cp -R "${HOME}/src/mingwrt-3.16-mingw32/include" "${HOME}/gcc/i386-mingw32"



现在,当我试图构建c(只)交叉编译器:


And now when I am trying to build the "c (only) cross-compiler":

cd "${HOME}/src/build-gcc/i386-mingw32/"
../../gcc-4.4.1/configure --prefix="${HOME}/gcc" --target=i386-mingw32 --enable-languages=c --with-headers="${HOME}/gcc/i386-mingw32/include" --disable-nls
make<br>

它正在构建大约4分钟,然后给我这些错误:

it was building something about 4 minutes and then gives me these errors:

${HOME}/gcc/i386-mingw32/bin/ld: dllcrt2.o: No such file: No such file or directory
collect2: ld returned 1 exit status
make[2]: *** [libgcc_s.dll] Error 1
make[2]: Leaving directory `${HOME}/src/build-gcc/i386-mingw32/i386-mingw32/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `${HOME}/src/build-gcc/i386-mingw32'
make: *** [all] Error 2

那个错误消息我真的不知道现在做什么: - ((。

From that error message I really don't know what to do now :-((( .



有人知道问题在哪里? br>
谢谢。


Does anybody know where is the problem?
Thanks.

推荐答案

这是真的:事情的方式,你需要

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


  1. 构建binutils

  2. 安装标题

  3. 足以创建对象文件,但不足以链接

  4. 构建win32api和mingw运行时(其中包括您缺少的 dllcrt2.o

  5. 构建一个完整的C编译器(以及其他前端,如C ++,Fortran,Ada等等)。

  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)

您已成功执行上述步骤3;它失败构建libgcc(这是一个GCC支持库),但这意味着C编译器核心是functionnal(虽然它将无法链接,它仍然可以创建有效的目标文件)。您可以通过查看GCC构建目录中的 gcc / xgcc 文件来检查。

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.

(要真正安装部分C编译器,您应该运行 make 使用 -k 选项,让它做到最好,即使面对错误,例如,使用 make - k install 。)

(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.)

这篇关于构建GCC交叉编译器(从“Linux”到“Windows”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆