|
Boost Users : |
Subject: Re: [Boost-users] boost compilation error
From: Dmitry V. Krivenok (krivenok_at_[hidden])
Date: 2009-01-16 07:32:13
Bijay Panda wrote:
> Hi,
> when i try like this i got error like bellow
> bijay_at_cmp1:~/boost$ g++ -o second boostThread.cpp
> -lboost_filesystem-gcc42-1_34_1
> /usr/bin/ld: cannot find -lboost_filesystem-gcc42-1_34_1
> collect2: ld returned 1 exit status
It can't find libboost_filesystem-gcc42-1_34_1.so
You may create it:
ln -s /usr/lib/libboost_filesystem-gcc42-1_34_1.so.1.34.1
/usr/lib/libboost_filesystem-gcc42-1_34_1.so
> so i tried like this
> bijay_at_cmp1: g++ -o second boostThread.cpp -L/boost_filesystem-gcc42-1_34_1
Read about -I and -L options in gcc manual page :)
>
> then it's showing error like bellow
Your program doesn't depend on boost filesystem library.
It depends on boost thread library.
>
> /tmp/cclxXala.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
>
Your program is compiled without any problems as follows:
krivenok_at_develop2 15:31:21 /tmp $ cat example.cpp
#include <boost/thread/thread.hpp>
#include <exception>
#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;
}
krivenok_at_develop2 15:31:28 /tmp $ g++ example.cpp
-lboost_thread-gcc43-mt-1_37 -L/usr/local/dev/boost-1.37.0/lib
-I/usr/local/dev/boost-1.37.0/include
krivenok_at_develop2 15:31:44 /tmp $ ./a.out
inside main
Throwing
Error: error
krivenok_at_develop2 15:31:47 /tmp $ ldd ./a.out
linux-gate.so.1 => (0xb7fa0000)
libboost_thread-gcc43-mt-1_37.so.1.37.0 =>
/usr/local/dev/boost-1.37.0/lib/libboost_thread-gcc43-mt-1_37.so.1.37.0
(0xb7f90000)
libstdc++.so.6 =>
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6 (0xb7e90000)
libm.so.6 => /lib/libm.so.6 (0xb7e6a000)
libgcc_s.so.1 =>
/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libgcc_s.so.1 (0xb7e5e000)
libc.so.6 => /lib/libc.so.6 (0xb7d2e000)
librt.so.1 => /lib/librt.so.1 (0xb7d24000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7d0d000)
/lib/ld-linux.so.2 (0xb7fa1000)
krivenok_at_develop2 15:31:55 /tmp $
> ////////////////////Here is my program///////////
> #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;
> }
>
> Plz help me out.
>
> On Fri, Jan 16, 2009 at 4:41 PM, Dmitry V. Krivenok
> <krivenok_at_[hidden] <mailto:krivenok_at_[hidden]>> wrote:
>
> Bijay Panda wrote:
>
> Hi,
> when i try this locate libboost_filesystem i get path like bellow
>
> bijay_at_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_at_cmp1:~/boost$
> then i tried to compile like this
>
> g++ -o second boostThread.cpp -lboost_filesystem
> -L/usr/lib/libboost_filesystem-gcc41-1_34_1.so.1.34.1
>
>
> The option "-L" specifies the directory containing the library
> (not the library itself).
> /usr/lib is standard path, so you can omit passing "-L" option.
>
> Try this:
> g++ -o second boostThread.cpp -lboost_filesystem-gcc42-1_34_1
>
> I always create symlinks like
> /usr/lib/libboost_filesystem.so --->
> /usr/lib/libboost_filesystem-gcc42-1_34_1.so
> after boost installation.
>
> This results to something like this:
>
> /usr/local/dev/boost-1.37.0/lib/libboost_filesystem.so ->
> /usr/local/dev/boost-1.37.0/lib/libboost_filesystem-gcc43.so //
> MANUALLY CREATED
> /usr/local/dev/boost-1.37.0/lib/libboost_filesystem-gcc43.so ->
> libboost_filesystem-gcc43-1_37.so.1.37.0 // AUTOMATICALLY CREATED
> BY BOOST
>
> This approach allows write Makefiles independent of gcc and boost
> versions.
> Instead of writing -lboost_filesystem-gcc42-1_34_1 you write
> -lboost_filesystem.
>
>
> It's strange that locate didn't find
>
> /usr/lib/libboost_filesystem-gcc42-1_34_1.so
> It should be symlink to
> /usr/lib/libboost_filesystem-gcc42-1_34_1.so.1.34.1
>
>
> it throws the same error.
>
> /usr/bin/ld: cannot find -lboost_filesystem
> collect2: ld returned 1 exit status
>
> Can u plz help me out.
>
> On Fri, Jan 16, 2009 at 1:14 PM, Dmitry V. Krivenok
> <krivenok_at_[hidden] <mailto:krivenok_at_[hidden]>
> <mailto:krivenok_at_[hidden]
> <mailto:krivenok_at_[hidden]>>> wrote:
>
> Bijay Panda wrote:
>
> Hi All,
> I am trying to run boost1.34.1 in ubuntu 7.10.
> Compiling the program like this
>
> g++ -o fst boostThread.cpp -lboost_filesystem
>
> throws error like bellow.
>
> /usr/bin/ld: cannot find -lboost_filesystem
> collect2: ld returned 1 exit status
>
> Can any one please tell me how to get rid of this.
>
>
> g++ can't find shared library libboost_filesystem.so
>
> Provide the path to the library using -L option.
> For example
> g++ -o fst boostThread.cpp -lboost_filesystem
> -L/usr/local/boost-1.34.1/lib
>
> If you don't know where library located try the following
> commands:
> sudo updatedb
> locate libboost_filesystem.so
>
> On my system this command produces this output:
> krivenok_at_develop2 10:44:55
> ~/dev_builds/boost-trunk/boost/date_time $ locate
> libboost_filesystem.so
> /usr/local/old_dev/boost-1.34.1/lib/libboost_filesystem.so
> /usr/local/dev/boost-1.37.0/lib/libboost_filesystem.so
> /usr/lib/libboost_filesystem.so
> krivenok_at_develop2 10:45:02
>
>
> -- Thanks & Regards
> Bijay Kumar Panda
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> <mailto:Boost-users_at_[hidden]>
> <mailto:Boost-users_at_[hidden]
> <mailto:Boost-users_at_[hidden]>>
>
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> -- Sincerely yours, Dmitry V. Krivenok
> Orange System Company
> Saint-Petersburg, Russia
> work phone: +7 812 332-32-40
> cellular phone: +7 921 576-70-91
> e-mail: krivenok_at_[hidden]
> <mailto:krivenok_at_[hidden]>
> <mailto:krivenok_at_[hidden]
> <mailto:krivenok_at_[hidden]>>
>
> web: http://www.orangesystem.ru
> skype: krivenok_dmitry
> jabber: krivenok_dmitry_at_[hidden]
> <mailto:krivenok_dmitry_at_[hidden]>
> <mailto:krivenok_dmitry_at_[hidden]
> <mailto:krivenok_dmitry_at_[hidden]>>
>
> icq: 242-526-443
>
>
>
>
> --
> Thanks & Regards
> Bijay Kumar Panda
> Mob-9739591816
> bijaykumar.mail_at_[hidden] <mailto:bijaykumar.mail_at_[hidden]>
> <mailto:bijaykumar.mail_at_[hidden]
> <mailto:bijaykumar.mail_at_[hidden]>>
> bijaykumar_panda_at_[hidden] <mailto:bijaykumar_panda_at_[hidden]>
> <mailto:bijaykumar_panda_at_[hidden]
> <mailto:bijaykumar_panda_at_[hidden]>>
>
>
>
> --
> Sincerely yours, Dmitry V. Krivenok
> Orange System Co., Ltd.
>
> Saint-Petersburg, Russia
> work phone: +7 812 332-32-40
> cellular phone: +7 921 576-70-91
> e-mail: krivenok_at_[hidden] <mailto:krivenok_at_[hidden]>
> web: http://www.orangesystem.ru
> skype: krivenok_dmitry
> jabber: krivenok_dmitry_at_[hidden] <mailto:krivenok_dmitry_at_[hidden]>
> icq: 242-526-443
>
>
>
>
> --
> Thanks & Regards
> Bijay Kumar Panda
> Mob-9739591816
> bijaykumar.mail_at_[hidden] <mailto:bijaykumar.mail_at_[hidden]>
> bijaykumar_panda_at_[hidden] <mailto:bijaykumar_panda_at_[hidden]>
>
-- Sincerely yours, Dmitry V. Krivenok Orange System Co., Ltd. Saint-Petersburg, Russia work phone: +7 812 332-32-40 cellular phone: +7 921 576-70-91 e-mail: krivenok_at_[hidden] web: http://www.orangesystem.ru skype: krivenok_dmitry jabber: krivenok_dmitry_at_[hidden] icq: 242-526-443
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net