Voici le nouveau MAkefile (avec minimode d'emploi)
Exemple de fonctionnement (il n'est pas parfait)
on va creer un executable tyto
Dans mon repertoire, j'ai 4 fichiers cpp BB_DS18B20.cpp essai.cpp gpioPin.cpp main.cppJe fabrique la bibliotheque bib1.a
Et maintenant, je fais un executable tyto a partir de main.cpp A noter que, avec cette structure, on peut mettre des libraries statiques et des executables ... n(importe où. C'est sympa pour des essais, mais un peu brdelique.
@ludovic : bravo pour le blanc du "; =" (mma vue est très mauvaise, et j'ai du mal à copier coller dans ce forum)
Code:
CC := g++CFLAGS := -Wall -g --pedantic -OsAR := /usr/bin/ar -crsTARGET := testAPP := essaiRM :=/usr/bin/rmSRCS := $(wildcard *.cpp)OBJS := $(patsubst %.cpp,%.o,$(SRCS))BIB := minilib.a# cosmetique dans ce casASTYLE := /usr/bin/astyle -d -xC80 -xL -s2 --style=googleall: $(TARGET) $(BIB)$(BIB): BB_DS18B20.o gpioPin.o$(AR) $@ $^ $(TARGET):$(APP).o $(BIB) $(CC) -o $@ $^ -lgpiod -lpthread%.o: %.cpp$(CC) $(CFLAGS) -c $<clean:$(RM) -rf $(TARGET) *.o# cosmetique, inutile dans ce casjoli:$(ASTYLE) *.cpp *.hpphelp:echo Aide à la construction d applications a partir de gpiod-cppecho de danjperronecho make BIB= nom de la bibliotheque à lier statiquement ex bib.aecho make TARGET = nom de l executable creeecho make APP = nom sans cpp du SEUL programme contenant un main
on va creer un executable tyto
Dans mon repertoire, j'ai 4 fichiers cpp BB_DS18B20.cpp essai.cpp gpioPin.cpp main.cpp
Code:
pi@raspberrypi:~/gpiod_cpp $ ls *.cppBB_DS18B20.cpp essai.cpp gpioPin.cpp main.cpp
Code:
pi@raspberrypi:~/gpiod_cpp $ make BIB=bib1.a/usr/bin/ar -crs bib1.a BB_DS18B20.o gpioPin.o g++ -o test essai.o bib1.a -lgpiod -lpthread // c'est une scorie, dont je me debarasserai peut etre(sert à tester la nouvelle bibliotheque)
Code:
pi@raspberrypi:~/gpiod_cpp $ make BIB=bib1.a APP=main TARGET=tytog++ -o tyto main.o bib1.a -lgpiod pi@raspberrypi:~/gpiod_cpp $ ls -l tyto-rwxr-xr-x 1 pi pi 203736 8 févr. 20:33 tyto
@ludovic : bravo pour le blanc du "; =" (mma vue est très mauvaise, et j'ai du mal à copier coller dans ce forum)
Statistics: Posted by dbrion1 — Thu Feb 08, 2024 7:42 pm