makefile setup with boost included

I'm trying to create a makefile for a small test file that includes various boost .hpp files.

I've created a makefile as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ cat makefile 
CC=g++
CFLAGS=-c -Wall -std=gnu++14 -L/usr/lib/x86_64-linux-gnu -lboost_thread -DBOOST_THREAD_VERSION=4 -lboost_system -ldl -lpq
all: small_test

small_test: follow_on.o small_test.o
		$(CC) small_test.o follow_on.o -o small_test 

follow_on.o:	follow_on.cpp
		$(CC) $(CFLAGS) follow_on.cpp

small_test.o: small_test.cpp
		$(CC) $(CFLAGS) small_test.cpp

clean:
		rm *o small_test.o small_test


small_test.cpp compiles, links and successfully runs when declaration and definition along with a small test in main are all in one file. I use Geany for development on Ubuntu.

My build command in Geany looks as follows:
g++ -g -Wall -std=c++14 -o "%e" "%f" /SQLAPI/lib/libsqlapi.a -lboost_thread -DBOOST_THREAD_VERSION=4 -lboost_system -ldl -lpq

But when I separate them out into separate .h and .cpp files and compile/link with make, I get the following link errors:
small_test.cpp:(.text+0x298): undefined reference to `boost::system::generic_category()'

Are the flags specified incorrectly ?
They match the ones I use in Geany, so I don't understand why linking error occurs.

Maybe it doesn't like for -lboost_system to be specified before small_test.o. I know ld is sensitive to linking order.
Topic archived. No new replies allowed.