Linking errors when compiling boost asio on Linux - c++

I have been running through a few tutorials of boost and the libraries it has.
I ran through the basic tutorial for boost:
http://www.boost.org/doc/libs/1_52_0/more/getting_started/unix-variants.html
and it worked fine. I am having issues with the asio tutorial:
http://www.boost.org/doc/libs/1_50_0/doc/html/boost_asio/tutorial/tutdaytime1/src.html
It looks like linking errors, but I am including the same path as before:
g++ -I /usr/local/boost_1_52_0 test.cpp -o example
Error:
/tmp/cce4EZME.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x57b): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x587): undefined reference to `boost::system::generic_category()'
test.cpp:(.text+0x593): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::system::error_code::error_code()':
test.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::asio::error::get_system_category()':
test.cpp:(.text._ZN5boost4asio5error19get_system_categoryEv[_ZN5boost4asio5error19get_system_categoryEv]+0x5): undefined reference to `boost::system::system_category()'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::~posix_thread()':
test.cpp:(.text._ZN5boost4asio6detail12posix_threadD2Ev[_ZN5boost4asio6detail12posix_threadD5Ev]+0x26): undefined reference to `pthread_detach'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::join()':
test.cpp:(.text._ZN5boost4asio6detail12posix_thread4joinEv[_ZN5boost4asio6detail12posix_thread4joinEv]+0x2b): undefined reference to `pthread_join'
/tmp/cce4EZME.o: In function `boost::asio::detail::posix_thread::start_thread(boost::asio::detail::posix_thread::func_base*)':
test.cpp:(.text._ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE[_ZN5boost4asio6detail12posix_thread12start_threadEPNS2_9func_baseE]+0x29): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status

assuming you have installed your boost libraries in your /usr/lib directory and boost header files in /usr/include/boost and you have saved your code in a file named daytime1.cpp, you have to use the following command to compile the source code you have linked to:
$ g++ daytime1.cpp -o daytime -L /usr/lib/ -lboost_system -lboost_thread -lpthread

Related

Error in opengl undefined reference to symbol

I am running an OpenGL C++ file with fragment and vertex files.
I am on Ubuntu 18.04.
The problem is that when I link with g++ command I get errors :
my first linking command was :
g++ -o proj prog.cpp -lGL -lm
and I am getting these errors :
/tmp/ccdaDttM.o: In function `main':
prog.cpp:(.text+0x18): undefined reference to `glfwInit'
prog.cpp:(.text+0x27): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x36): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x45): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x54): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x63): undefined reference to `glfwWindowHint'
prog.cpp:(.text+0x84): undefined reference to `glfwCreateWindow'
prog.cpp:(.text+0x9f): undefined reference to `glfwGetFramebufferSize'
prog.cpp:(.text+0xd3): undefined reference to `glfwTerminate'
prog.cpp:(.text+0xe9): undefined reference to `glfwMakeContextCurrent'
prog.cpp:(.text+0xef): undefined reference to `glewExperimental'
prog.cpp:(.text+0xf5): undefined reference to `glewInit'
prog.cpp:(.text+0x22c): undefined reference to `__glewGenVertexArrays'
prog.cpp:(.text+0x241): undefined reference to `__glewGenBuffers'
prog.cpp:(.text+0x256): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x264): undefined reference to `__glewBindBuffer'
prog.cpp:(.text+0x277): undefined reference to `__glewBufferData'
prog.cpp:(.text+0x293): undefined reference to `__glewVertexAttribPointer'
prog.cpp:(.text+0x2bc): undefined reference to `__glewEnableVertexAttribArray'
prog.cpp:(.text+0x2ca): undefined reference to `__glewVertexAttribPointer'
prog.cpp:(.text+0x2f3): undefined reference to `__glewEnableVertexAttribArray'
prog.cpp:(.text+0x301): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x314): undefined reference to `glfwWindowShouldClose'
prog.cpp:(.text+0x326): undefined reference to `glfwPollEvents'
prog.cpp:(.text+0x368): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x38a): undefined reference to `__glewBindVertexArray'
prog.cpp:(.text+0x39d): undefined reference to `glfwSwapBuffers'
prog.cpp:(.text+0x3a9): undefined reference to `__glewDeleteVertexArrays'
prog.cpp:(.text+0x3be): undefined reference to `__glewDeleteBuffers'
prog.cpp:(.text+0x3d1): undefined reference to `glfwTerminate'
/tmp/ccdaDttM.o: In function `Shader::Shader(char const*, char const*)':
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x27b): undefined reference to `__glewCreateShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x28f): undefined reference to `__glewShaderSource'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2af): undefined reference to `__glewCompileShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2c0): undefined reference to `__glewGetShaderiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x2e7): undefined reference to `__glewGetShaderInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x347): undefined reference to `__glewCreateShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x35b): undefined reference to `__glewShaderSource'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x37b): undefined reference to `__glewCompileShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x38c): undefined reference to `__glewGetShaderiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x3b3): undefined reference to `__glewGetShaderInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x413): undefined reference to `__glewCreateProgram'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x427): undefined reference to `__glewAttachShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x443): undefined reference to `__glewAttachShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x45f): undefined reference to `__glewLinkProgram'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x473): undefined reference to `__glewGetProgramiv'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x49d): undefined reference to `__glewGetProgramInfoLog'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x500): undefined reference to `__glewDeleteShader'
prog.cpp:(.text._ZN6ShaderC2EPKcS1_[_ZN6ShaderC5EPKcS1_]+0x511): undefined reference to `__glewDeleteShader'
/tmp/ccdaDttM.o: In function `Shader::Use()':
prog.cpp:(.text._ZN6Shader3UseEv[_ZN6Shader3UseEv]+0xf): undefined reference to `__glewUseProgram'
collect2: error: ld returned 1 exit status
When I googled, I found this post : undefined reference to `__glewCreateShader`
and according to the post, I changed the command to :
g++ -o proj prog.cpp -lGLEW -lm
The long list of errors is reduced but still :
/usr/bin/ld: /tmp/ccSaE0MX.o: undefined reference to symbol 'glDrawArrays'
//usr/lib/x86_64-linux-gnu/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
I viewed several posts and they almost say the same thing
OpenGL library not linking
The command I tried :
g++ -o proj prog.cpp -lGLEW -lm -lGLU -lglut
g++ -o proj prog.cpp -lGL -lGLEW -lm
g++ -o proj prog.cpp -lGLEW -lGL -lm
g++ -o proj prog.cpp -lGLEW -lopengl32 -lm
g++ prog.cpp -lGL -lGLU -lGLEW -lGLFW -lm
g++ prog.cpp -lGL -lGLU -lGLEW -lglut -lm -o proj
include :
#include <iostream>
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "Shader.h"
Update :
here is what I am getting now
g++ -o proj sample.cpp libglut.a -lGL -lm
/usr/bin/ld: libglut.a(glut_event.o): undefined reference to symbol 'XWithdrawWindow'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Please tell me what am I doing wrong.
Thanks

g++ linking to external library creates undefined references

I'm trying to build a simple program to test the use of an external library but am having trouble linking it with g++. See command/results:
user#user-Nuvo-2510VTC:~/Desktop/WDT_DIO/linux/test$ g++ -o main main.o -lwdt_dio
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `sem_unlink'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `pthread_mutexattr_settype'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `sem_close'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `pthread_spin_lock'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `pthread_spin_unlock'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `pthread_create'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `pthread_spin_init'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `pthread_mutexattr_init'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `pthread_spin_destroy'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `sem_post'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `sem_open'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `sem_getvalue'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `sem_wait'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwdt_dio.so: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
It looks like it isn't linking to some basic libraries that are part of the OS?
Details:
gcc --version --> 5.4.0 20160609
ldd --version --> 2.23
OS --> Ubuntu 16.04 x64, 4.8.0-36-generic kernel
You seem to be missing a link to the pthread library. Add -pthread to your compilation command:
g++ -o main main.o -pthread -lwdt_dio
Checking the man page for sem_wait(3) shows:
Link with -pthread.
Note: sem_wait was selected randomly, all of them should specify that
If you read the errors closely it says that the undefined comes from libwdt_dio.so. It also says to which function you have an undefined reference.
In this particular case, it is the pthread library. It should probably be mentioned as a dependency in WDT lib documentation.
You can add -pthread to your g++ command if you're compiling through the command line.

Built and static linked boost modules causes a bunch of linker errors with shutdown_service() [duplicate]

This question already has answers here:
undefined reference to boost::system::system_category() when compiling
(9 answers)
Closed 7 years ago.
I'm trying to get select boost modules built and into my code as static libraries for what we need for our project. I seem to be able to get them to build using their Boost.Build system, and my project will compile using boost shared libraries, but when I try to link static, they break.
I built Boost using the following:
./b2 link=static variant=release threading=multi --with-iostreams --with-system --with-timer --ignore-site-config
Which give success
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/mike/dev/cpp/boost_1_60_0
The following directory should be added to linker library paths:
/home/mike/dev/cpp/boost_1_60_0/stage/lib
Then I try to compile using my makefile with autotools:
tunnel_CPPFLAGS = -march=native -pipe -funroll-loops -fomit-frame-pointer -fforce-addr -fprefetch-loop-arrays -Wall -std=c++0x -I/home/mike/dev/cpp/boost_1_60_0/
tunnel_SOURCES = tunneller/tunnel.cpp config.cpp util.cpp tunneller/remoteclient.cpp tunneller/localclient.cpp
tunnel_LDADD = -lcrypto -lssl
tunnel_LDFLAGS = -pthread -Wl,-Bstatic -L/home/mike/dev/cpp/boost_1_60_0/stage/lib -lboost_iostreams -lboost_timer -lboost_system -Wl,-Bdynamic
Which returns this fantastic error:
make all-recursive
make[1]: Entering directory '/home/mike/dev/cpp/sonar'
Making all in src
make[2]: Entering directory '/home/mike/dev/cpp/sonar/src'
g++ -g -O2 -pthread -Wl,-Bstatic -L/home/mike/dev/cpp/boost_1_60_0/stage/lib -lboost_iostreams -lboost_timer -lboost_system -Wl,-Bdynamic -o tunnel tunneller/tunnel-tunnel.o tunnel-config.o tunnel-util.o tunneller/tunnel-remoteclient.o tunneller/tunnel-localclient.o -lcrypto -lssl
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::task_io_service::shutdown_service()':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::op_queue<boost::asio::detail::task_io_service_operation>::~op_queue()':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::epoll_reactor::deregister_descriptor(int, boost::asio::detail::epoll_reactor::descriptor_state*&, bool)':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::reactive_socket_service_base::destroy(boost::asio::detail::reactive_socket_service_base::base_implementation_type&)':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `boost::asio::detail::reactive_socket_service_base::destroy(boost::asio::detail::reactive_socket_service_base::base_implementation_type&)':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o:/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: more undefined references to `boost::system::system_category()' follow
tunneller/tunnel-tunnel.o: In function `_GLOBAL__sub_I__Z14printUsageExitv':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
tunneller/tunnel-tunnel.o: In function `_GLOBAL__sub_I__Z14printUsageExitv':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o: In function `std::default_delete<tunnel::LocalClient>::operator()(tunnel::LocalClient*) const [clone .isra.247]':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o: In function `tunnel::RemoteClient::authenticationSuccess()':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o: In function `tunnel::RemoteClient::RemoteClient(boost::asio::io_service&, boost::asio::ssl::context&, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, std::string, std::string, std::string)':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o:/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: more undefined references to `boost::system::system_category()' follow
tunneller/tunnel-remoteclient.o: In function `_GLOBAL__sub_I__ZN6tunnel12RemoteClientC2ERN5boost4asio10io_serviceERNS2_3ssl7contextENS2_2ip23basic_resolver_iteratorINS8_3tcpEEESsSsSs':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
tunneller/tunnel-remoteclient.o: In function `_GLOBAL__sub_I__ZN6tunnel12RemoteClientC2ERN5boost4asio10io_serviceERNS2_3ssl7contextENS2_2ip23basic_resolver_iteratorINS8_3tcpEEESsSsSs':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o: In function `tunnel::LocalClient::handleConnect(boost::system::error_code)':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o: In function `tunnel::LocalClient::handleConnect(boost::system::error_code)':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o: In function `tunnel::LocalClient::handleConnect(boost::system::error_code)':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o:/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: more undefined references to `boost::system::system_category()' follow
tunneller/tunnel-localclient.o: In function `_GLOBAL__sub_I__ZN6tunnel11LocalClientC2EPNS_12RemoteClientERN5boost4asio10io_serviceERNS4_2ip23basic_resolver_iteratorINS7_3tcpEEERt':
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/home/mike/dev/cpp/boost_1_60_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
tunneller/tunnel-localclient.o: In function `_GLOBAL__sub_I__ZN6tunnel11LocalClientC2EPNS_12RemoteClientERN5boost4asio10io_serviceERNS4_2ip23basic_resolver_iteratorINS7_3tcpEEERt':
/home/mike/dev/cpp/boost_1_60_0/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
collect2: error: ld returned 1 exit status
Makefile:385: recipe for target 'tunnel' failed
make[2]: *** [tunnel] Error 1
make[2]: Leaving directory '/home/mike/dev/cpp/sonar/src'
Makefile:355: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/mike/dev/cpp/sonar'
Makefile:296: recipe for target 'all' failed
make: *** [all] Error 2
What am I missing to get this to compile properly?
The problem is not when compiling, it is when it trying to link.
The order in which -l option is given matters So, try giving -lboost_system as first in -l options.
-pthread -Wl,-Bstatic -L/home/mike/dev/cpp/boost_1_60_0/stage/lib -lboost_system -lboost_iostreams -lboost_timer -Wl,-Bdynamic

undefined reference to `boost::system::system_category(), but I already have -lboost_system

Getting this error from a cpp library I'm trying to port from Linux to Windows, using code::blocks. I'm new to c++ in general but especially new to Windows and CB.
I'm pretty sure I have added the system library accordingly, by which I mean I have compiled it using:
.\b2 -j 8 variant=release link=shared threading=single
Then gone to the lib directory, found boost_system-vc120-1_55.dll and renamed it boost_system.dll
The added F:\plus\boost\boost_1_55_0\stage\lib to the Build options, search directories, linker. (And F:\plus\boost\boost_1_55_0\ in search directories, compiler)
The -lboost_system is after the cpp files in the compile command, although for some reason it's listed twice, but I tried compiling in command prompt without the first one and gave same error.
This is the build output I get:
-------------- Build: Release in sendd (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -LF:\plus\wxWidgets-3.0.2\lib\gcc_dll -LF:\plus\boost\boost_1_55_0\stage\lib -o bin\Release\sendd.exe obj\Release\gsmencoding.o obj\Release\hexdump.o obj\Release\pdu.o obj\Release\senddApp.o obj\Release\senddMain.o obj\Release\smpp.o obj\Release\smppclient.o obj\Release\sms.o obj\Release\timeformat.o obj\Release\resource.res -s -mthreads -lwsock32 -lws2_32 -lboost_system -lwxmsw30u -lboost_system -mwindows
obj\Release\smppclient.o:smppclient.cpp:(.text+0x724): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0x769): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0xb28): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0xf28): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0xfaf): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text+0x13a5): more undefined references to `boost::system::system_category()' follow
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x1b): undefined reference to `boost::system::generic_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x25): undefined reference to `boost::system::generic_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x2f): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x39): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x43): undefined reference to `boost::system::system_category()'
obj\Release\smppclient.o:smppclient.cpp:(.text.startup+0x4d): undefined reference to `boost::system::system_category()'
Any ideas? Thanks!

Getting unexpected "undefined reference to" errors when compiling with a static library

I've been trying to make a static library out of this: https://github.com/onlinecity/cpp-smpp , as I'd like to make a single file executable that uses it.
So far I have gone into src/smpp/ and created the .o files with:
g++-5 -c *.cpp -std=c++11 -I.
Then made them into an .a file with:
ar rvs libsmpp.a *.o
Then I'm trying to compile a small main.cpp file that uses the library with this:
g++-5 main.cpp -I/usr/local/include -static libsmpp.a -lboost_system -lboost_regex -lboost_date_time -lpthread -lm -lglog -lgflags -std=c++11
And I get some undefined reference errors:
/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a(condition_variable.o): In function `std::condition_variable::~condition_variable()':
(.text._ZNSt18condition_variableD2Ev+0x1): undefined reference to `pthread_cond_destroy'
/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a(condition_variable.o): In function `std::condition_variable::wait(std::unique_lock<std::mutex>&)':
(.text._ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE+0x8): undefined reference to `pthread_cond_wait'
libsmpp.a(smppclient.o): In function `smpp::SmppClient::sendPdu(smpp::PDU&)':
smppclient.cpp:(.text+0x22a1): undefined reference to `google::LogMessage::LogMessage(char const*, int)'
smppclient.cpp:(.text+0x22b0): undefined reference to `google::LogMessage::stream()'
smppclient.cpp:(.text+0x22d4): undefined reference to `google::LogMessage::~LogMessage()'
smppclient.cpp:(.text+0x2534): undefined reference to `google::LogMessage::~LogMessage()'
libsmpp.a(smppclient.o): In function `smpp::SmppClient::readPdu(bool const&)':
smppclient.cpp:(.text+0x29d8): undefined reference to `google::LogMessage::LogMessage(char const*, int)'
smppclient.cpp:(.text+0x29e7): undefined reference to `google::LogMessage::stream()'
smppclient.cpp:(.text+0x2a0b): undefined reference to `google::LogMessage::~LogMessage()'
smppclient.cpp:(.text+0x2a48): undefined reference to `google::LogMessage::~LogMessage()'
libsmpp.a(smppclient.o): In function `boost::asio::detail::posix_event::~posix_event()':
smppclient.cpp:(.text._ZN5boost4asio6detail11posix_eventD2Ev[_ZN5boost4asio6detail11posix_eventD5Ev]+0x14): undefined reference to `pthread_cond_destroy'
libsmpp.a(smppclient.o): In function `boost::asio::detail::posix_event::posix_event()':
smppclient.cpp:(.text._ZN5boost4asio6detail11posix_eventC2Ev[_ZN5boost4asio6detail11posix_eventC5Ev]+0x2e): undefined reference to `pthread_cond_init'
libsmpp.a(smppclient.o): In function `void boost::asio::detail::posix_event::wait<boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex> >(boost::asio::detail::scoped_lock<boost::asio::detail::posix_mutex>&)':
smppclient.cpp:(.text._ZN5boost4asio6detail11posix_event4waitINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_[_ZN5boost4asio6detail11posix_event4waitINS1_11scoped_lockINS1_11posix_mutexEEEEEvRT_]+0x5f): undefined reference to `pthread_cond_wait'
libsmpp.a(timeformat.o): In function `boost::date_time::month_formatter<boost::gregorian::greg_month, boost::date_time::iso_format<char>, char>::format_month(boost::gregorian::greg_month const&, std::ostream&)':
timeformat.cpp:(.text._ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo[_ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo]+0x33): undefined reference to `boost::gregorian::greg_month::as_short_string() const'
timeformat.cpp:(.text._ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo[_ZN5boost9date_time15month_formatterINS_9gregorian10greg_monthENS0_10iso_formatIcEEcE12format_monthERKS3_RSo]+0x56): undefined reference to `boost::gregorian::greg_month::as_long_string() const'
collect2: error: ld returned 1 exit status
It compiles fine when I link to a dynamic version of the smpp library, although that's made using the cmake files included with the smpp lib. I didn't know how to modify them to output a static library, so I just used the g++ command at the top, and added the libraries listed in them (like glog) in the main.cpp compile command.
The "undefined reference to google::logMessage" seems especially strange, as I'm pretty sure thats part of glog, which is definitely loaded and included in the smppclient.cpp file itself.
Any ideas? Thanks.