Skip to content
Arthur Sonzogni edited this page May 17, 2023 · 1 revision

Makefile with pkg-config

Starting from v5.0.0 in this patch, FTXUI populate a pkg-config file. You can depend on FTXUI using a Makefile like this one

CC = g++
CFLAGS = -g -Wall
FTXUI_CFLAGS  = `pkg-config --cflags ftxui`
FTXUI_LDFLAGS = `pkg-config --libs ftxui`
 
all: run

run: main
	./main
 
main: main.o
	$(CC) main.o $(FTXUI_LDFLAGS) -o main
 
main.o: main.cpp
	$(CC) -c main.cpp $(CFLAGS) $(FTXUI_CFLAGS) -o main.o
 
clean:
	rm main.o
	rm main

Makefile without pkg-config

Without pkg-config, this translates into something similar to:

CC = g++
CFLAGS = -g -Wall
FTXUI_CFLAGS  = -I/usr/local/include
FTXUI_LDFLAGS = -L/usr/local/lib -lftxui-component -lftxui-dom -lftxui-screen
 
all: run

run: main
	./main
 
main: main.o
	$(CC) main.o $(FTXUI_LDFLAGS) -o main
 
main.o: main.cpp
	$(CC) -c main.cpp $(CFLAGS) $(FTXUI_CFLAGS) -o main.o
 
clean:
	rm main.o
	rm main
Clone this wiki locally