Reputation: 267
I am trying to make my first Makefile for a simple server using boost sockets.
I can get the code to run under windows.
To get it to run under linux I run the command
c++ -I /var/boost/boost_1_55_0/ Source.cpp -o source -lboost_system
I have a make file http://pastebin.com/QTms69Kd
However when I run it I get errors like undefined reference to `boost::system::generic_category()'
I got that error before when I forgot the boost_system in my command. What I am doing wrong?
Upvotes: 0
Views: 1220
Reputation: 4549
Your Makefile
looks right and I would normally expect it to work on linux.
You are right to link boost::system
. The boost::asio
library is "header only" but it uses the boost::system
library for error messages, so boost::system
must be linked into the build.
However, their are a couple of complications with linking boost libraries. Firstly the location of the library may be necessary in addition to the library itself, e.g.:
LDFLAGS := -L/path/to/boost_1_55_0/built_library_directory -lboost_system
Secondly, boost
addd suffixes to the library names to define boost version and possibly the compiler.
So boost_system
on Windows becomes:
libboost_system-vc140-mt-1_60.lib // MSVC 2015, boost 1.60
libboost_system-mgw49-mt-1_60.a // MinGW, boost 1.60
Whilst on a Fedora installation (in /usr/lib64):
libboost_system.a
libboost_system.so // symbolic link to:
libboost_system.so.1.60.0 // gcc, boost 1.60
So I think that your issue is not with your Makefile
, but how you have built the boost
libraries and where you have put them.
Also, why are you using such an old version of boost
?
Upvotes: 1