boost compilation error,plz help

For topics that do not fit in another sub-forum.

Moderator: Oberlus

Post Reply
Message
Author
bijay_panda
Space Krill
Posts: 5
Joined: Fri Jan 16, 2009 12:20 pm

boost compilation error,plz help

#1 Post by bijay_panda »

Hi All,
I am trying to compile boost in ubuntu 7.10.
Here is the path of installation in my pc
bijay@cmp1:~/boost$ locate libboost_filesystem
/usr/lib/libboost_filesystem-gcc41-mt-1_34_1.so.1.34.1
/usr/lib/libboost_filesystem-gcc42-1_34_1.so.1.34.1
/usr/lib/libboost_filesystem-gcc42-mt-1_34_1.so.1.34.1
/usr/lib/libboost_filesystem-gcc41-1_34_1.so.1.34.1
/var/cache/apt/archives/libboost_filesystem-gcc41-mt-1_34_1.so.1.34.1
/var/cache/apt/archives/libboost_filesystem-gcc42-1_34_1.so.1.34.1
/var/cache/apt/archives/libboost_filesystem-gcc42-mt-1_34_1.so.1.34.1
/var/cache/apt/archives/libboost_filesystem-gcc41-1_34_1.so.1.34.1
bijay@cmp1:~/boost$

when i try a program like bellow

#include <exception>
#include <boost/thread/thread.hpp>
#include <stdlib.h>
#include <iostream>
using namespace std;

class callable {
public:
void run()
{
try
{
cout << "Throwing" <<std:: endl;
throw string("error");
}
catch(string &e)
{
cout << "Error: " << e << endl;
}
}

void operator()() {
this->run();
}
};

int main() {
callable c;
cout<<"inside main"<<endl;
boost::thread thd(boost::ref(c));
thd.join();
return 0;
}

after compiling like
bijay@cmp1:~/boost$ g++ -o second boostThread.cpp -L/user/lib/libboost_filesystem-gcc42-1_34_1

it throws error like bellow

/tmp/ccv5r3IM.o: In function `main':
boostThread.cpp:(.text+0xeb): undefined reference to `boost::thread::thread(boost::function0<void, std::allocator<boost::function_base> > const&)'
boostThread.cpp:(.text+0x101): undefined reference to `boost::thread::join()'
boostThread.cpp:(.text+0x132): undefined reference to `boost::thread::~thread()'
boostThread.cpp:(.text+0x148): undefined reference to `boost::thread::~thread()'
collect2: ld returned 1 exit status

Please Please any one help me out.
Thanks in advance
Bijay Panda.

User avatar
OndrejR
Space Dragon
Posts: 339
Joined: Thu Oct 02, 2008 11:00 pm
Location: Slovakia

Re: boost compilation error,plz help

#2 Post by OndrejR »

Upgrade ubuntu to 8.10. You have boost 1.34, which is out of date. And continue compiling by wiki howto.

stride
Space Floater
Posts: 31
Joined: Sun Sep 28, 2008 3:05 pm
Location: Horten, Norway

Re: boost compilation error,plz help

#3 Post by stride »

bijay_panda wrote:Hi All,
I am trying to compile boost in ubuntu 7.10.
...

Please Please any one help me out.
Thanks in advance
Bijay Panda.
It's possible to get it all up and running on your distro, if you choose not upgrading, but it can be quite a lot of work. If available packages doesn't have high enough version numbers go for compiling and installing the newer ones from source. Almost all *-devel and *-lib packages can perfectly well coexist in different versions on the same system.

To get better separation from packages that come with your system you might still want to install in another location (/usr/local/lib and /usr/local/include) than where your standard packages usually gets installed (/lib, /usr/lib and /usr/include).

Try running "./configure --help" etc. in source packages to get a list of install options and locations before compiling and installing.

M.

User avatar
kroddn
Static Linker
Posts: 347
Joined: Thu Jun 28, 2007 10:28 am

Re: boost compilation error,plz help

#4 Post by kroddn »

The problem ist that libboost_filesystem is not enough to link or maybe even the wrong lib. I think you need libboost_thread instead of libboost_filesystem, as you are using threads and not filesystems.

bijay_panda
Space Krill
Posts: 5
Joined: Fri Jan 16, 2009 12:20 pm

Re: boost compilation error,plz help

#5 Post by bijay_panda »

Hi,
I already installed the library in all of the path bellow.
/user/local/lib
/user/local/include
/user/lib
Still the same error it's showing.

stride wrote:
bijay_panda wrote:Hi All,
I am trying to compile boost in ubuntu 7.10.
...

Please Please any one help me out.
Thanks in advance
Bijay Panda.
It's possible to get it all up and running on your distro, if you choose not upgrading, but it can be quite a lot of work. If available packages doesn't have high enough version numbers go for compiling and installing the newer ones from source. Almost all *-devel and *-lib packages can perfectly well coexist in different versions on the same system.

To get better separation from packages that come with your system you might still want to install in another location (/usr/local/lib and /usr/local/include) than where your standard packages usually gets installed (/lib, /usr/lib and /usr/include).

Try running "./configure --help" etc. in source packages to get a list of install options and locations before compiling and installing.

M.

bijay_panda
Space Krill
Posts: 5
Joined: Fri Jan 16, 2009 12:20 pm

Re: boost compilation error,plz help

#6 Post by bijay_panda »

Hi,
I did that but the same error.I am not getting the what linking problem it's getting.
all the libraries are there in these path
/user/lib
/user/local/lib
/user/local/include

bijay@cmp1:~/boost$ g++ -o second boostThread.cpp -L/user/lib/libboost_thread-mt.so
/tmp/ccLrbfvL.o: In function `main':
boostThread.cpp:(.text+0xeb): undefined reference to `boost::thread::thread(boost::function0<void, std::allocator<boost::function_base> > const&)'
boostThread.cpp:(.text+0x101): undefined reference to `boost::thread::join()'
boostThread.cpp:(.text+0x132): undefined reference to `boost::thread::~thread()'
boostThread.cpp:(.text+0x148): undefined reference to `boost::thread::~thread()'
collect2: ld returned 1 exit status
bijay@cmp1:~/boost$

Just have a look at it plz plz plz.
kroddn wrote:The problem ist that libboost_filesystem is not enough to link or maybe even the wrong lib. I think you need libboost_thread instead of libboost_filesystem, as you are using threads and not filesystems.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: boost compilation error,plz help

#7 Post by Geoff the Medio »

You're not building boost properly. Go the the boost site and read their getting started guide. I believe you need to use boost.jam.

User avatar
kroddn
Static Linker
Posts: 347
Joined: Thu Jun 28, 2007 10:28 am

Re: boost compilation error,plz help

#8 Post by kroddn »

You are not using it the right way.

Try

Code: Select all

g++ -o second boostThread.cpp -L/user/lib/ -llibboost_thread-mt
-L defines a search path for libs
-l defines one lib to link the program with. This must be specified WITHOUT .so suffix.

Its not a good idea to start with working on boost if you don't know how to work with g++ commands. Maybe you should start with gcc tutorials and/or Makefiles.

stride
Space Floater
Posts: 31
Joined: Sun Sep 28, 2008 3:05 pm
Location: Horten, Norway

Re: boost compilation error,plz help

#9 Post by stride »

bijay_panda wrote:Hi,
I did that but the same error.I am not getting the what linking problem it's getting.
all the libraries are there in these path
/user/lib
/user/local/lib
/user/local/include
Also... beware that when compiling and installing boost "out of the box" with standard configuration; the names of libraries will include your compiler and threading info in them, like this:

Code: Select all

/usr/local/lib/libboost_date_time-gcc40-mt-1_37.a
/usr/local/lib/libboost_date_time-gcc40-mt-1_37.so
/usr/local/lib/libboost_date_time-gcc40-mt-1_37.so.1.37.0
/usr/local/lib/libboost_date_time-gcc40-mt.a
/usr/local/lib/libboost_date_time-gcc40-mt.so
/usr/local/lib/libboost_filesystem-gcc40-mt-1_37.a
/usr/local/lib/libboost_filesystem-gcc40-mt-1_37.so
/usr/local/lib/libboost_filesystem-gcc40-mt-1_37.so.1.37.0
/usr/local/lib/libboost_filesystem-gcc40-mt.a
/usr/local/lib/libboost_filesystem-gcc40-mt.so
/usr/local/lib/libboost_graph-gcc40-mt-1_37.a
/usr/local/lib/libboost_graph-gcc40-mt-1_37.so
/usr/local/lib/libboost_graph-gcc40-mt-1_37.so.1.37.0
/usr/local/lib/libboost_graph-gcc40-mt.a
/usr/local/lib/libboost_graph-gcc40-mt.so
.a files is for static linking, .so's for dynamic linking and loading. Also make sure the loader is aware of your shared libraries location (ldconfig and paths). Here is some info regarding static and dynamic libraries: http://www.learncpp.com/cpp-tutorial/a1 ... -libraries
Last edited by Geoff the Medio on Tue Jan 20, 2009 10:37 am, edited 1 time in total.
Reason: fixed url BBCode

Post Reply