1

I'm trying my hand at C++, I've got Eclipse on my Arch machine. I'm trying to get an example at Boost.Org working:

#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

int main()
{
  boost::asio::io_context io;

  boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
  t.wait();

  std::cout << "Hello, world!" << std::endl;

  return 0;
}

I've downloaded the library tar and extracted it to /usr/local/include as this appeared the most obvious from the default include folders, but I still got the following error: Unresolved inclusion: <boost/asio.hpp>

Any suggestions?

UPDATE: Just needed to give Eclipse time to acknowledge the library being moved to /usr/local/include (a default include folder).

aSystemOverload
  • 2,994
  • 18
  • 49
  • 73
  • I'd be surprised if arch doesn't have boost in the actual package repository (whatever it is that arch uses). Why not use that directly? – Stephen Newell Mar 24 '18 at 22:15
  • If you are just starting with C++, chances are you don't want to jump straight away to Boost. Please have a look at this [C++ books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) list. – Ron Mar 24 '18 at 22:15
  • Have you tried googling "eclipse configure library include paths"? You can point your IDE at the place you decided it made sense to install your libraries, rather than groping around for places the IDE might already search. – Tony Delroy Mar 24 '18 at 22:18
  • I like to do things manually, to help me understand what is going on. I'm looking at Boost because my current goal is to create an app/service that can communicate with instances of itself on other machines on the network. Saw that Boost was advised as a good library for this. – aSystemOverload Mar 24 '18 at 22:19
  • @TonyDelroy as I said, I extracted the library to the /usr/local/include folder which was one of the default include folders. – aSystemOverload Mar 24 '18 at 22:22
  • Boost::asio's pretty good for that. Some docs on adding header search locations to eclipse: https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_proj_paths.htm . Found by googling: add include folder to eclipse – user4581301 Mar 24 '18 at 22:22
  • Is this a compilation error or eclipse error? – user7860670 Mar 24 '18 at 22:23
  • Looks like Eclipse was just taking its time, as it's now lost the error on the #include. Thank you everyone for your input! – aSystemOverload Mar 24 '18 at 22:23
  • 1
    If I remember correctly ASIO is one of the Boost packages that requires some special care and feeding to build. You're probably not out of the water just yet. – user4581301 Mar 24 '18 at 22:23
  • Nothing in your answer or comments above says `/usr/local/include` was a default include path *for Eclipse*. You only say it's an obvious place to install to. I'm suggesting you check Eclipse configuration to make sure it's actually looking in `/usr/local/include`. Anyway, good to hear it was. May be worth updating your question with "UPDATE: I just had to wait for Eclipse to notice boost..." and list the manual triggering VTT mentions below, as that may help future readers. – Tony Delroy Mar 24 '18 at 22:25
  • 1
    You may need to manually trigger reindexing of header files by opening context menu for project -> Index -> Rebuild. Also note that eclipse indexer is rather glitchy and does not support even some pre C++11 code. So you may have a rather hard time utilizing boost libraries. – user7860670 Mar 24 '18 at 22:26
  • @VTT Oooh, thanks, didn't see that option. I was going with 'PROJECT / REFRESH' – aSystemOverload Mar 24 '18 at 22:30

1 Answers1

1

You should just run

pacman -S boost

this will install boost in the system include path that GCC always uses.

Jean-Michaël Celerier
  • 7,412
  • 3
  • 54
  • 75