C++ compiler for Linux on Windows? [closed]

2019-08-08 04:01发布

问题:

I'm fully aware of this question asking for the same thing. That question is closed and rather old. Accepted answer suggests rather complicated way of making your own cross-compiler and it requires cygwin.

Maybe now there are some other, simpler ways of doing this?

回答1:

Actually, there is. If you want cross-compile for linux on ARM, you can use linaro toolchain, which is available for windows. It doesn't require cygwin.

If you want cross-compile for linux on x86, that's a bit of a problem. The only ready-to-use toolchain (apart pre-built solution in that answer) that I'm aware of is "cross-compile tools" for Intel Edison (here). There are some drawbacks to it:

  1. It will compile 32-bit linux binary
  2. Version for windows 64-bit requires cygwin
  3. Version for Windows 32-bit doesn't require cygwin but contains case-sensitive filenames (i.e. there are some files with names that differ only in case and windows will consider them the same file). You may have to make your Windows case-sensitive.

Windows binaries will be at "sysroots\x86_64-pokysdk-mingw32\usr\bin\i586-poky-linux"

To use edison toolchain you have to provide it with sysroot option for compilation and linking, something like this:

"i586-poky-linux-g++.exe" --sysroot=../../../../core2-32-poky-linux


回答2:

ELLCC is available as a binary download for Windows, Linux, and Macs. It doesn't require cygwin, and can build Linux programs for several targets, including ARM. It is based on the clang/LLVM compiler.