0

I am a first time C++ user, and I have been working for 8 hours trying to build and compile the simple "Hello World" program with C++ in Visual Studio Code. I have CygWin64, but I'm not sure if it's connected to my VSCode. I have installed the extensions C/C++, C/C++ Compile Run, C++ Intellisense, Clang-Format, and Easy C++ projects.

So far I have tried

#include <iostream.h>
 main()
 {
     cout<< "Hi there";
    return 0;
 }

and

 #include <iostream.h>
 int main() {
    std::cout << "Hello Easy C++ project!" << std::endl;
}

Using iostream.h helped me to get to work (it wouldn't at first), but I'm not sure if that is helpful, since other posts say that .h is very archaic. I have also tried editing my c_cpp_properties.json file. Sadly, I still get the message:

"> Executing task: bash -c "make run" < 'bash' is not recognized as an internal or external command, operable program or batch file. The terminal process terminated with exit code: 1 Terminal will be reused by tasks, press any key to close it."

I am not sure if I need to install an alternative to Clang (I haven't found one), or run something initially on Cygwin64.

I have been looking online for suggestions and following pages such as https://dev.to/acharluk/developing-c-with-visual-studio-code-4pb9 and https://github.com/Microsoft/WSL/issues/1598, but I still can't seem to get around this problem.

Any help would be very appreciated. Thanks, Anne

A. Las
  • 1
  • Can you run bash in your terminal? – Daniel Jan 18 '19 at 23:44
  • 1
    Unless you are being forced to suffer, don't waste your time with Visual Studio Code on Windows. Download and use a [community version of Visual Studio](https://visualstudio.microsoft.com/vs/community/). This is an all in one package with very little you need to around with in order to get up and running. Once you have a better understanding of the whys and wherefores of C++ that will come from using the language you'll be in a much better position to fiddle with Visual Studio Code and Cygwin. – user4581301 Jan 18 '19 at 23:54
  • 1
    On second look, `` hasn't existed since long-lost days of yore. Take caution if you are learning from materials that reference this header because they are teaching a pre-Standardization version of C++ from back in the 1980s and early 1990's. What you will find is kind-of the opposite of [Why doesn't a simple “Hello World”-style program compile with Turbo C++?](https://stackoverflow.com/questions/44863062/why-doesnt-a-simple-hello-world-style-program-compile-with-turbo-c), modern compilers will not accept this code. – user4581301 Jan 19 '19 at 00:13
  • @Daniel, Thank you so much for your response. No, I don't think bash runs in my terminal, which is why I think I need to do something to get the Cygwin64 and the VSC talking. – A. Las Jan 19 '19 at 02:03
  • @user4581301 I will look into installing a community-system. Some of the tutorials I have seen use a VS community--I just didn't want to be totally reliant on a Windows product, since my professor believes that linus/mac is king, and I'm not sure how flexible the community platforms are. – A. Las Jan 19 '19 at 02:04
  • @Daniel, I also tried using these directions: https://stackoverflow.com/questions/42606837/how-do-i-use-bash-on-windows-from-the-visual-studio-code-integrated-terminal, but no success yet. – A. Las Jan 19 '19 at 02:25
  • I appreciate not wanting to be locked to a single vendor or operating system. Once you get familiar with C++, play around with a bunch of different tools until you find one that fits the way you think and work. Eclipse is a tool that works well on Windows, Linux, and Mac and is (to me) easier to set up than VS Code (For now. VS Code is in its infancy and Microsoft has a habit of not getting up to full steam until around version 4. Eclipse has about a 20 year head start.) That said Eclipse is a bloated pig and when it goes wrong it *really* goes wrong. Versatility is a curse sometimes. – user4581301 Jan 19 '19 at 02:53
  • Wild veering into opinion here. The best development environments target one language and preferably [are written in that language](https://en.wikipedia.org/wiki/Eating_your_own_dog_food). The highly configurable, program everything IDEs always come off feeling like the language it was written in is the King and the rest of the languages are serfs. The developers find and fix the IDE's problems with their home language because they face them first and every day until they're fixed. Everyone else is filing bug reports and praying. – user4581301 Jan 19 '19 at 03:03
  • @Daniel and anyone else having this problem. I used this site: stackoverflow.com/questions/42606837/… and found it helpful. Now I have bash running in my terminal and I'm trying to fix the problem I have with the compilerpath. I'm using github.com/Microsoft/vscode-cpptools/issues/1863 for others with this problem. When I tried to update my includePath, I got stuck again, so I tried to start again from scratch, downloading minGW, but then I was never able to get gcc or g++ recognized in my command window. I think I will uninstall everything and start from the very beginning again. – A. Las Jan 19 '19 at 06:17

0 Answers0