C++ Makefile %.c works, %.cpp not? -
i wrting simple makefile c++ files here problem not understand. have 2 folders
/src .cpp files
- main.cpp
- check cpp
/include .hpp files
- check.hpp
my makefiles looks this
libs = -lsfml-graphics -lsfml-window -lsfml-system cc = g++ vpath = src include cppflags = -i include ### files ### obj = main.o check.o ### rules ### all: sfml-app sfml-app: $(obj) $(cc) -o sfml-app $(obj) $(libs) %.o: %.c $(cc) -c $< clean: rm -rf *o $(obj)
if use makefile likes this, works fine. if change %.o: %.c %.o: %.cpp said
src/main.cpp:2:21: critical error: check.hpp: file or folder not found
is wrong write .cpp instead of .c c++ project? confused me bit. why .c works finde , .cpp not.
thanks :) !
the flags variable c++ language called cxxflags
, , should using $(cxx)
instead of $(cc)
in code. cppflags
variable preprocessor arguments.
Comments
Post a Comment