Skip to content

Commit 5910a87

Browse files
committed
fix: Update library linking for Linux and macOS in makefiles
1 parent bf59a92 commit 5910a87

3 files changed

Lines changed: 23 additions & 20 deletions

File tree

examples/ImGui/makefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,21 +271,19 @@ endif
271271

272272
ifeq ($(IS_LINUX),yes)
273273
# GLFW on Linux
274-
LIBS += -lglfw
275-
276-
# OpenGL + X11 stack
277-
LIBS += -lGL -ldl -lpthread
278-
LIBS += -lXrandr -lXinerama -lXcursor -lXi
274+
LIBS += `pkg-config --static --libs glfw3`
279275
endif
280276

281277
ifeq ($(IS_MACOS),yes)
282-
LIBS += -lglfw
278+
BREW_PREFIX := $(shell brew --prefix 2>/dev/null || echo /usr/local)
279+
280+
CXXFLAGS += -I$(BREW_PREFIX)/include
281+
LIBS += -L$(BREW_PREFIX)/lib
282+
283+
LIBS += `pkg-config --static --libs glfw3`
283284

284285
# macOS frameworks (use -framework instead of -l)
285286
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
286-
LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib
287-
288-
CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include
289287
endif
290288

291289
# Final linker command ingredients

examples/task-manager/makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,19 @@ ifeq ($(IS_WINDOWS),yes)
268268
endif
269269

270270
ifeq ($(IS_LINUX),yes)
271-
# OpenGL + X11 stack
272-
LIBS += -lGL -ldl -lpthread
273-
LIBS += -lXrandr -lXinerama -lXcursor -lXi
271+
LIBS +=
274272
endif
275273

276274
ifeq ($(IS_MACOS),yes)
275+
BREW_PREFIX := $(shell brew --prefix 2>/dev/null || echo /usr/local)
276+
277+
CXXFLAGS += -I$(BREW_PREFIX)/include
278+
LIBS += -L$(BREW_PREFIX)/lib
279+
280+
LIBS +=
281+
277282
# macOS frameworks (use -framework instead of -l)
278283
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
279-
LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib
280-
281-
CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include
282284
endif
283285

284286
# Final linker command ingredients

templates/advanced/makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,20 @@ ifeq ($(IS_WINDOWS),yes)
268268
endif
269269

270270
ifeq ($(IS_LINUX),yes)
271-
# OpenGL + X11 stack
272-
LIBS += -lGL -ldl -lpthread
271+
LIBS += -lGL -lX11 -ldl -lpthread
273272
LIBS += -lXrandr -lXinerama -lXcursor -lXi
274273
endif
275274

276275
ifeq ($(IS_MACOS),yes)
276+
BREW_PREFIX := $(shell brew --prefix 2>/dev/null || echo /usr/local)
277+
278+
CXXFLAGS += -I$(BREW_PREFIX)/include
279+
LIBS += -L$(BREW_PREFIX)/lib
280+
281+
LIBS +=
282+
277283
# macOS frameworks (use -framework instead of -l)
278284
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
279-
LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib
280-
281-
CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include
282285
endif
283286

284287
# Final linker command ingredients

0 commit comments

Comments
 (0)