Adding a library (boost)

CodeLite installation/troubleshooting forum
tomjoad
CodeLite Curious
Posts: 4
Joined: Mon Apr 18, 2011 11:44 pm
Genuine User: Yes
IDE Question: c++
Contact:

Adding a library (boost)

Post by tomjoad »

I'm using the newest version of CodeLite on Ubuntu 10.10 and am trying to add boost, but cant figure out the correct way to do it. The directory is /usr/boost/boost_1_46_1/

I right click on the project and go to settings. I then go to common settings -> linker and from there I have "options," "library paths," and "libraries" input boxes. I have tried everything I can think of to get it to work, but I cannot. I tried googling, but found nothing. I tried searching these forums, but found nothing.

What exactly do I need to put in those three fields to make it work?
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding a library (boost)

Post by eranif »

Please provide the info request here:

http://codelite.org/forum/viewtopic.php ... &sk=t&sd=a

Eran
Make sure you have read the HOW TO POST thread
tomjoad
CodeLite Curious
Posts: 4
Joined: Mon Apr 18, 2011 11:44 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Adding a library (boost)

Post by tomjoad »

Codelite version: 2.10.0.4778
OS: Ubuntu 10.10

Build output:

Code: Select all

----------Build Started--------
/bin/sh -c '"make"  -j 2 -f "LinuxJobCrawler_wsp.mk"'
----------Building project:[ testing - Debug ]----------
make[1]: Entering directory `/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing'
g++ -c  "/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing/main.cpp" -g  -o ./Debug/main.o -I. -I. 
/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing/main.cpp:3: fatal error: /boost/lambda/lambda.hpp: No such file or directory
compilation terminated.
make[1]: *** [Debug/main.o] Error 1
make[1]: Leaving directory `/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing'
make: *** [All] Error 2
----------Build Ended----------
1 errors, 0 warnings


Source:

Code: Select all

#include <stdio.h>

#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
    using namespace boost::lambda;
    typedef std::istream_iterator<int> in;

    std::for_each(
        in(std::cin), in(), std::cout << (_1 * 3) << " " );
	return 0;
}
Right click on the project and go to settings. Then go to linker. In the library paths box I put "/usr/boost/boost_1_46_1/" I tried several variations of the path, but none appear to work. I am obviously missing something.

I have not run BJAM or gone beyond trying to use the header only library used in boost's example. I always go one step at a time, then test, and build on top of that.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding a library (boost)

Post by eranif »

tomjoad wrote:Right click on the project and go to settings. Then go to linker. In the library paths box I put "/usr/boost/boost_1_46_1/"
I am not sure if you are aware of this, but you are failing in the "compilation" stage not in the linker (you haven't got there yet...)
tomjoad wrote:/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing/main.cpp:3: fatal error: /boost/lambda/lambda.hpp: No such file or directory
You need to add boost to the search path for include files so the compiler could pick it up.

right click on the project go to settings | common settings | compiler, and add the path to boost's location in the 'Include paths'

Eran
Make sure you have read the HOW TO POST thread
tomjoad
CodeLite Curious
Posts: 4
Joined: Mon Apr 18, 2011 11:44 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Adding a library (boost)

Post by tomjoad »

::::EDIT::::
The below-post has more to do with me not understanding how the example works. It appears to work fine after some messing around. However, this problem persists:
However, when I right click on the #include <.../lamba.hpp> and click "open include file." Nothing happens. It works for the other include files.


=================ORIGINAL POST====================

Thank you for your help. I added /usr/boost/boost_1_46_1/ to where you said and it successfully builds.

Code: Select all

----------Build Started--------
/bin/sh -c '"make"  -j 2 -f "LinuxJobCrawler_wsp.mk"'
----------Building project:[ testing - Debug ]----------
make[1]: Entering directory `/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing'
make[1]: Leaving directory `/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing'
make[1]: Entering directory `/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing'
g++ -c  "/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing/main.cpp" -g  -o ./Debug/main.o -I. -I/usr/boost/boost_1_46_1/ 
g++ -o ./Debug/testing ./Debug/main.o  -L.   
make[1]: Leaving directory `/mnt/hgfs/Shared/Linux - JobCrawler/LinuxJobCrawler/testing'
----------Build Ended----------
0 errors, 0 warnings
I deleted the link entry from above -- it still builds.

However, when I right click on the #include <.../lamba.hpp> and click "open include file." Nothing happens. It works for the other include files. Also, the output is not working.

When I follow the instructions from boost it does work. ( http://www.boost.org/doc/libs/1_46_1/mo ... sing-boost )
Now, in the directory where you saved example.cpp, issue the following command:

c++ -I path/to/boost_1_46_1 example.cpp -o example

To test the result, type:

echo 1 2 3 | ./example
The output is 3 6 9
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Adding a library (boost)

Post by eranif »

tomjoad wrote:I deleted the link entry from above -- it still builds.
Well, this is because boost is mostly hpp files (templates) - so there is no implementation, you only needs to include the header files - but this is not related to codelite, but simply understanding C++ templates and they work.
tomjoad wrote:The below-post has more to do with me not understanding how the example works. It appears to work fine after some messing around. However, this problem persists:
However, when I right click on the #include <.../lamba.hpp> and click "open include file." Nothing happens. It works for the other include files.
You need to add the files to the parser's search path (for code-completion)

from the main menu: 'Settings | Tags Settings | Include Files' and add the boost path (e.g. /usr/boost/boost_1_46_1) to the 'search paths' (you might need to full retag your workspace after its done: from the main menu: Workspace | Retag Workspace (full) )



Eran
Make sure you have read the HOW TO POST thread
tomjoad
CodeLite Curious
Posts: 4
Joined: Mon Apr 18, 2011 11:44 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Adding a library (boost)

Post by tomjoad »

Eran:

Thank you so much for all of your help. I have gotten everything working (haven't tried the code-completion yet) -- to include linking libraries (like regex).

I have one more question: Can the application be built statically without boost first being built statically? If so, how would I do that? If not, looks like I have some work to do with bjam...

This is the first time I've tried to use boost, ubuntu and a new ide at the same time. I learned a lot using QT (on W7), but I need something smaller for my next program that will work on Ubuntu, and CodeLite was by far the easiest IDE to just pick up, quickly understand the basics, and start coding with (to include Code::Blocks, KDevelop 4, and Eclipse).
Post Reply