Now I'm learning C ++. I want a makefile that compiles all cpp files in the current directory to separate executable files. For example:
There are 3 C ++ files in the directory, for example examp1.cpp, examp2.cpp and examp3.cpp . I want a makefile that will compile and link them, and give examp1.exe, examp2.exe and examp3.exe
I created a bash script to compile them all and create exes, but I think; this is not the exact way to do this.
I have a Makefile for ".c", but this does not seem to work here. It creates only object files and does not link them. It looks like this:
SRCS=$(wildcard *.c) OBJS=(SRCS:.c=.o) all: $(OBJS)
The above code compiles all new and changed โ.cโ files into โ.oโ files with the same name in the current directory.
The bash script I use to create executables is:
for i in ./*.cpp do g++ -Wno-deprecated $i -o `basename $i .cpp`".exe" done
This means that I want all the โ.cppโ files to be placed in this directory using a simple โmake allโ or something similar that it should compile.
kaushik
source share