-1

I am trying to use Microsoft REST SDK to create a server listening to HTTP requests. My current computer is Ubuntu 18.04, the server code is pretty simple.

I have already installed the library by following the instructions on libboost official website and I have checked files in /usr/local/lib/, there are libboost_random.so.1.68.0 so I presume that I have libboost library.

However when I try to compile the code with the following command:

g++ server.cpp -o server -lpthread -lcpprest -lcrypto -lssl -lboost_system

It shows:

/tmp/ccKWADuo.o: In function `boost::system::system_category()':
server.cpp:(.text._ZN5boost6system15system_categoryEv[_ZN5boost6system15system_categoryEv]+0x7): undefined reference to `boost::system::detail::system_category_instance'
/tmp/ccKWADuo.o: In function `boost::system::generic_category()':
server.cpp:(.text._ZN5boost6system16generic_categoryEv[_ZN5boost6system16generic_categoryEv]+0x7): undefined reference to `boost::system::detail::generic_category_instance'
collect2: error: ld returned 1 exit status

Thanks for any advices.

Jamie Cui
  • 1
  • 4
  • Have you checked there aren't any warnings further up in the compiler output? – Alan Birtles Jan 10 '19 at 06:51
  • @AlanBirtles no, nothing, I have pasted eveything on this post, I wonder if it's because of the version of boost library. – Jamie Cui Jan 10 '19 at 06:53
  • 1
    Maybe relevant... [undefined reference to boost::system::system_category() when compiling](https://stackoverflow.com/q/9723793/608639) – jww Jan 10 '19 at 07:22

2 Answers2

0

Boost consists of several independent libraries. Your linker error suggests you are missing libboost_system.so. You just mentioned libboost_random.so to be in your /usr/local/lib but is there also the required libboost_system.so?

Wyverex
  • 15
  • 6
  • yes, it is in `/usr/local/lib/`, sorry for the confusing statement. In fact, under that path there are `libboost_system.so` and `libboost_system.so.1.68.o` – Jamie Cui Jan 10 '19 at 07:20
0

[Problem solved] Reinstalling library libboost 1.68.0 helps. Error occurs when building from source, fixing those building errors will solve the problem.

Jamie Cui
  • 1
  • 4