MakeFile help

I am trying to compile a simple program. This is my code

1
2
3
4
5
6
LIBS= ~/Documents/c++\ Projects/MakeFIle_2/MakeFIle_2
all:
	for dir in *.cpp; do \
		g++ -c $$dir -o hello ; \
		cd -; \
	done


But the problem is i always got this eror

1
2
/bin/sh: line 0: cd: OLDPWD not set
/bin/sh: line 0: cd: OLDPWD not set


Can someone help me whats the problem on that code?
Please show the whole makefile. As it stands, it appears you don't actually have the proper dirctories to cd into or files to build.

You're saying that "*.cpp" is a list of directories, and you want g++ to iteratively cd to these directories and build hello from a missing source

Also, what you're doing is trying to treat a makefile like a shell script, success is unlikely. I suggest you try and lookup how to run scripts fro the makefile, or use sub-shell commands instead.
Topic archived. No new replies allowed.