|
Boost Users : |
From: Mike Feldmeier (pooky_bunny_at_[hidden])
Date: 2004-05-25 10:57:37
>From: "Ben Hutchings" <ben.hutchings_at_[hidden]>
>Reply-To: boost-users_at_[hidden]
>To: <boost-users_at_[hidden]>
>Subject: RE: [Boost-users] boost::thread, boost::bind, and member functions
>Date: Tue, 25 May 2004 12:07:32 +0100
>
>Mike Feldmeier <pooky_bunny_at_[hidden]> wrote:
> > I've seen variations of this come up in this newsgroup and elsewhere,
> > but I have yet to find an answer that works for me.
> >
> > class threaded_manager
> > {
> > public:
> > void start(void);
> > };
> >
> > threaded_manager mgr;
> >
> > boost::thread(boost::bind(&threaded_manager::start, &mgr));
> >
> > This consistently produces the linking error:
> >
> > converter.obj : error LNK2019: unresolved external symbol
> > "__declspec(dllimport) public: __thiscall boost::thread::thread(class
> > boost::function0<void,class
> > _STL::allocator<class boost::function_base> > const &)"
> > (__imp_??0thread_at_boost@@QAE_at_ABV?$function0_at_XV?$allocator_at_Vfunction_bas
> > e_at_boost@@@_STL@@@1@@Z) referenced in function "public: void __thiscall
> > mytest::test::converter::run(void)"
> > (?run_at_converter@test_at_mytest@@QAEXXZ)
>
>I think you aren't linking with the thread library. Many of the Boost
>libraries (such as Boost.Bind) include their implementation entirely in
>header files, so they will be compiled into your program as needed.
>Boost.Thread doesn't; you need to build it as a library (and on Windows
>it must be a DLL) and link it with your program.
>
I'm using Visual C++ 7.1, but using straight C++, no .NET. I've defined the
addtional library path (C:\boost\lib) and tried linking (in the additional
dependencies) with boost_thread-vc71-mt-gdp-1_31.lib,
boost_thread-vc71-mt-gdp.lib, boost_thread-vc71-mt-p-1_31.lib, and
boost_thread-vc71-mt-p.lib (one at a time, of course), but I get the same
error message with all of them.
> > Separating the two boost functions on to separate lines works fine:
> >
> > boost::bind(&threaded_manager::start, &mgr);
> > boost::thread();
> >
> > ..which indicates to me that bind is returning an object that is not
> > compatible with thread, but I've seen multiple examples of just this
> > type of call.
><snip>
>
>If that were the case you should see a compiler error. The two lines
>above may work because the default constructor for boost::thread is
>compiled inline whereas the other constructor must be linked in.
>Having said that, though, neither v1.30 nor v1.31 has the default
>constructor definition in the header, so I don't entirely understand
>what's going on. Did you perhaps mistakenly declare a function
>returning a boost::thread?
>
Thus far, this line (or two lines) are the only boost-related lines in my
code.
>Ben.
>
>_______________________________________________
>Boost-users mailing list
>Boost-users_at_[hidden]
>http://lists.boost.org/mailman/listinfo.cgi/boost-users
Thanks,
Mike
_________________________________________________________________
Get 200+ ad-free, high-fidelity stations and LIVE Major League Baseball
Gameday Audio! http://radio.msn.click-url.com/go/onm00200491ave/direct/01/
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