linkerautotoolsautomake

Automake makefile doesn't link properly


I am building a project with Automake and I want to link GLFW and GLEW to the project. My Makefile.am looks like this:

AUTOMAKE_OPTIONS = foreign subdir-objects
bin_PROGRAMS = game
game_SOURCES = src/main.cpp
game_CXXFLAGS =
game_LDFLAGS = $(glfw3_LIBS) $(glew_LIBS)

This does not compile as the libraries are listed first in the linking command:

$ make
...
g++   -g -O2 -lglfw -lGLEW -lGLU -lGL  -o game src/game-main.o
...

How can I fix this?


Solution

  • The solution was to use _LDADD instead of _LDFLAGS.