开发者

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

Trying to port Visual Studio solution to开发者_JS百科 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...


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 $@ $<
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜