'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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source