且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 Windows 到 Linux 的 C++ 交叉编译器

更新时间:2023-10-22 23:22:04

crosstool-ng 支持使用 cygwin 主机构建交叉编译器.

概述:

  • 使用开发包安装 cygwin
  • 下载crosstool-ng
  • 解压压缩包 (tar xvjf crosstool-ng*)
  • 运行./configure
  • 当 configure 提示缺少工具时,返回 cygwin setup 并安装相应的包(例如 flexlibtoolncurses-devel>) 您至少需要以下内容:
    • 开发/gperf
    • 开发/野牛
    • 开发/byacc
    • 开发/wget
    • 开发/补丁
    • 开发/制作(GNU 版本)
    • 开发/自动制作 1.10+
    • 库/libncursesw10
    • 库/libncursesw10-devel
    • Install cygwin, with development packages
    • Download crosstool-ng
    • Extract the tarball (tar xvjf crosstool-ng*)
    • Run ./configure
    • When configure complains about a missing tool, go back to cygwin setup and install the corresponding package (e.g. flex, libtool, ncurses-devel) You'll need at least the following:
      • Devel/gperf
      • Devel/bison
      • Devel/byacc
      • Devel/wget
      • Devel/patch
      • Devel/make (GNU version)
      • Devel/automake 1.10+
      • Libs/libncursesw10
      • Libs/libncursesw10-devel
      • the _libintl_gettext error as mentioned in the comments
      • the byteshift headers, and
      • the ELF headers (Thanks Duncan Calvert & osm0sis)

      当然,这不会使您能够从 Visual Studio 内部构建 linux 应用程序.(VS2010 及更高版本允许您使用其他工具链(例如 gcc)进行构建,但是除了由 crosstool-ng 构建的交叉编译器之外,您还需要适当的工具链描述).但是您将拥有一个有效的 g++-linux-gnu,您可以直接运行或使用 Makefile.

      Of course, this is NOT going to enable you to build linux applications from inside Visual Studio. (VS2010 and later let you build with other toolchains such as gcc, but you'd need an appropriate toolchain description in addition to the cross-compiler built by crosstool-ng). But you'll have a working g++-linux-gnu, which you can either run directly or using a Makefile.

      注意:构建交叉编译器需要很长时间.osm0sis 提供了这里提供了一个预构建的 gcc 4.8.1,以及他关于构建交叉编译器的笔记(用于更新此答案).

      NOTE: Building the cross-compiler takes a LONG time. osm0sis has provided a prebuilt gcc 4.8.1 here, along with his notes on building the cross-compiler (used to update this answer).