运行 GCC on Bash on Windows 10 with C# or C++

Run GCC on Bash on Windows 10 with C# or C++

我想 运行 gccbash 上用 C#C++ 做一点 IDE。我尝试使用 cmd 运行 gcc:bash gcc --version(--version 只是一个示例)但它显示错误:/usr/bin/gcc: /usr/bin/gcc: Can't run the file

所以我想我需要 C#C++ 中的特定命令?或者我可以直接在 bash 上 运行 gcc 吗?

我建议在您的系统上安装 Cygwin

bash shell 是 Cygwin

支持的众多项目之一

您需要确保在 Bash 中安装了 gcc,然后才能从 Bash 或 Windows.

中调用它

一个简单的方法是安装 build-essential 伪包,它将引入 GCC/G++ 和许多其他常用的开发工具、库等:

$ sudo apt-get install build-essential

完成此操作后,运行 gcc --version 来自 Bash 以确保其可访问:

$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

现在您应该能够从 cmd/PowerShell/CreateProcess/Process.Create()/etc:

调用 gcc
C:\> bash -c "gcc --version"
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

HTH