且构网

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

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

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

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

概述:


  • 使用开发包安装cygwin

  • 下载 crosstool-ng

  • 解压缩档( tar xvjf crosstool-ng *

  • 运行 ./ configure

  • 当配置提示缺少工具时,回到cygwin安装程序并安装相应的包 flex libtool ncurses-devel 需要至少以下:


    • Devel / gperf

    • Devel / bison

    • Devel / byacc

    • Devel / wget

    • Devel / patch


    • Devel / automake 1.10 +

    • Libs / libncursesw10

    • Libs / 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).