简体   繁体   中英

Having trouble configuring VS code for c++ programs

I am having some troubles compiling c++ programs in VS code. I followed this answer: How do I set up Visual Studio Code to compile C++ code?

and my Makefile is

CC=g++
CFLAGS=-Wall
.SUFFIXES = .cpp
objs:=$(wildcard *.cpp)
targets:=$(objs:.cpp= )

.PHONY:all
all: $(targets)
.cpp:
    $(CC) $(CFLAGS) -std=c++11 -o $@ $< 

I just want to compile this file which is opened in current window, say 1.cpp and this file does not have any external dependencies

When i try to compile my file (by pressing f8 as given in the answer i linked) i get the following error:

'make' is not recognized as an internal or external command,
operable program or batch file.

I am a beginner, and don't know much about Makefile , any help will be appreciated. Thanks!
Edit: I am using Windows subsystem for linux to compile my programs not mingw or cygwin.

Edit:
Now i can use make but i think something is wrong with my Makefile. 在此处输入图片说明

I have figured out a simple way:
args doesn't work some reason at least on my system.

So, change command (line 3 of tasks.json)

"command": "g++ -Wall -std=c++14 ${relativeFile};./a.out < input.txt

And now just one button and compile and run!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM