0

Trying to compile a boost C++ code I have found out that one needs to name the libraries to be used explicit. So, given the following code:

#include<iostream>
#include<boost/filesystem/operations.hpp>

namespace bfs=boost::filesystem;
int main()
{
    bfs::path p("second.cpp");
    if(bfs::exists(p))
    std::cout<<p.leaf()<<std::endl;
}

I am able to compile (and link) it with the following command line

g++   -o main main.cpp -lboost_filesystem -lboost_system

How can I define those -l libraries in eclipse, so that eclipse is able to compile (and link) the code without an undefined reference error?

This is a question on the usage and configuration of eclipse.

Alex
  • 41,580
  • 88
  • 260
  • 469
  • Possible duplicate of: [Problems importing libraries to my c++ project, how to fix this?](http://stackoverflow.com/questions/24715864/problems-importing-libraries-to-my-c-project-how-to-fix-this) – πάντα ῥεῖ Nov 12 '14 at 16:57
  • This is not a duplicate, because the question you link to is in no way related to eclipse. My question is an exclusive eclipse question, I am not asking a question about the 'undefined reference' error. Please read question carefully next time. – Alex Nov 12 '14 at 16:59
  • Your question is answered there for Eclipse as well as for some other IDEs. Or isn't it? – πάντα ῥεῖ Nov 12 '14 at 17:04
  • I see there are many ways to set the libraries. Well, I guess your link might answer it, although it does not mention explicitly to set the used libraries in one of the windows. – Alex Nov 12 '14 at 17:08

1 Answers1

0

You need to go to

Project -> Properties

and then add the libraries you want to use manually. See screenshot:

enter image description here

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Alex
  • 41,580
  • 88
  • 260
  • 469
  • So what is this C/C++ General section for then? I tried this solution and it works. So why is this wrong? – Alex Nov 12 '14 at 17:09
  • Seems to work equally, though I never used these settings to setup build configurations, just to make stuff available for the indexer. – πάντα ῥεῖ Nov 12 '14 at 18:09