我想用 C#
或 C++
在 bash
上运行 gcc
这样我就可以制作一个小的 IDE它。我尝试使用 cmd 运行 gcc:bash gcc --version
(--version 只是一个示例)但它显示错误:/usr/bin/gcc:/usr/bin/gcc: 无法运行文件
所以我想我需要一个 C#
或 C++
的特定命令?或者我可以直接在 bash
上运行 gcc
吗?
最佳答案
您需要确保在 Bash 中安装了 gcc,然后才能从 Bash 或 Windows 调用它。
一个简单的方法是安装 build-essential
伪包,它将引入 GCC/G++ 和许多其他常用的开发工具、库等:
$ sudo apt-get install build-essential
完成此操作后,从 Bash 中运行 gcc --version
以确保它可以访问:
$ 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
关于c# - 使用 C# 或 C++ 在 Windows 10 上的 Bash 上运行 GCC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40615226/