gcc - C++ makefile building multiple dll and project structuring -


i have tried searching answer no avail, given project has got following structure

makefile ./src    strings.cpp    networking.cpp ./bin    strings.dll    networking.dll ./build    strings.o    networking.o ./include    strings.h    networking.h ./lib    boost 

i new makefiles , research have done far have managed (not complicated, know)

cc = g++  src = src/strings.cpp out = bin/strings.dll obj = build/strings.o  inc= -i include  all: strings.dll  strings.dll: strings.o     $(cc) -shared -o $(out) $(obj)   strings.o: $(src)      $(cc) $(inc) -dbdll -c $(src) -o $(obj) 

the issues/questions have

1- goes through whole compilation process, when have not changed source code ?

2- how make things more 'effective' ? saw examples of people using wildcards , such, had difficulty following along. use wildcards begin since want separate dlls each target ?

3 - lets introduced algorithms.h , algorithms.cpp recommended way of including in build ?

thanks help, appreciate it

first. whole compilation process goes because make search target "strings.dll" build bin/strings.dll. if replace to

bin/strings.dll: strings.o      $(cc) -shared -o $(out) $(obj)  bin/strings.o: $(src)       $(cc) $(inc) -dbdll -c $(src) -o $(obj) 

build of targets (bin/strings.o , bin/strings.dll) performed if prerequisite changed.

second - wildcards used search files inside directory this: $(whildcard *.cpp) evaluates cpp file inside current directory. can write this:

all_sources = $(wildcard *.cpp) all_objects = $(addprefix bin/,$(all_sources:.cpp=.o))  all: bin/strings.dll  bin/strings.dll: $(all_objects)     <how build strings.dll objects>  bin/%.o: %.cpp     <how build objects inside bin dir cpp of current dir>     

third - makefile not build system tool has domain specific language. can write own build system using make. if want ready build better study automake/cmake/... many of them.

also beginning start using make tool. don't stop , surprise how power inside it.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -