0

Attempting to create a simple WebSocket c++ application, the library I am using relies on boost. I have attempted to add boost to my project but it refuses to compile, heres my cpp file

#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>

#include <websocketpp/common/thread.hpp>
#include <websocketpp/common/memory.hpp>

#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <sstream>

main()
{
    printf("Hello World\n");
    return 0;
}

I am attemting to compile it with g++ -I. -Iboost_1_58_0 /home/cabox/workspace/main.cpp -o /home/cabox/workspace/bin/exe, but all i get is

In function `__static_initialization_and_destruction_0(int,int)':                                                            
main.cpp:(.text+0xfba): undefined reference to`boost::system::generic_category()'

My folder layout is just my Main.cpp file, the boost_1_58_0 & the websocketpp folders all being in the same parent directory, what is it I'm doing wrong?

James T
  • 1,155
  • 4
  • 17
  • 39

1 Answers1

1

Add

-lboost_system

(see also What is an undefined reference/unresolved external symbol error and how do I fix it?)

Optionally specify the library directory with -L

Make sure it's after the cpps

Undefined reference to boost::system::generic_category despite linking with boost_system

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • When i add this, it says it cannont find boost_system. – James T May 21 '15 at 13:02
  • "_Optionally specify the library directory with -L_" (see also the two linked answers in case you need more background explanation) – sehe May 21 '15 at 13:03
  • Read [some documentation](http://www.boost.org/doc/libs/1_58_0/more/getting_started/index.html). After you build, it's usually `-/boost_1_58_0/stage/lib/` (default build settings). – sehe May 21 '15 at 13:18
  • I have tried following the linked documentation but that didnt work either, also i dont have /stage/lib in my boost directory.. I'll attempt to redownload see if that's the problem. – James T May 21 '15 at 13:19
  • That is not the problem. Did you build? There's bound to be FAQs on building boost on your system. Otherwise, ask a focused question about it. Be sure to specify exactly what you tried and where you are stuck. – sehe May 21 '15 at 13:21