1

Trying to port Visual Studio solution to Linux, is there anyway to g++ a whole directory recursively?

There are lots of files to compile and before making a clean makefile I'd like to simply compile once and see what it gives...

1

1 Answer 1

2

You can try using find like below:

find . -name *.cpp -exec g++ -c {}\;

It's also easy to create a wildcard make file do to the compile and linking for you:

CC = g++
COMPILE = $(CC) -c
OBJF := $(patsubst %.cpp,%.o,$(wildcard *.cpp))

all: prog

prog: $(OBJF)
      $(CC) -o prog $(OBJF)

%.o: %.cpp
      $(COMPILE) -o $@ $<
1
  • You may like to make target "all" phony. Jan 30, 2011 at 23:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.