Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to run gcc on bash with C# or C++ so I can make a little IDE for it. I tried to run gcc with cmd: bash gcc --version (--version is just a example) but it shows the error: /usr/bin/gcc: /usr/bin/gcc: Can't run the file

So i guess i need a specific command in C# or C++? Or can i somehow run gcc on bash directly?

like image 248
DevNoteHQ Avatar asked Dec 15 '22 02:12

DevNoteHQ


1 Answers

You need to ensure you've got gcc installed in Bash before you can invoke it from Bash or from Windows.

An easy way to do this is to install build-essential pseudo-package which will bring in GCC/G++ and a host of other commonly required dev tools, libs, etc:

$ sudo apt-get install build-essential

Once you've done this, run gcc --version from within Bash to make sure it's reachable:

$ 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.

Now you should be able to invoke gcc from cmd/PowerShell/CreateProcess/Process.Create()/etc:

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

like image 162
Rich Turner Avatar answered Dec 16 '22 14:12

Rich Turner