Boost logo

Threads-Devel :

From: Florian (robotik_at_[hidden])
Date: 2008-02-14 11:44:41


Hello,

I read this message and thought it might related to my problem.
Something is missing when my main.cpp is not compiled along with the
Boost-thread code of tss.cpp:

main.cpp is the the standard clock example:

#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>
#include <iostream>

struct thread_alarm
{
    thread_alarm(int secs) : m_secs(secs) { }
    void operator()()
    {
        boost::xtime xt;
        boost::xtime_get(&xt, boost::TIME_UTC);
        xt.sec += m_secs;

        boost::thread::sleep(xt);

        std::cout << "alarm sounded..." << std::endl;
    }

    int m_secs;
};

int main(int argc, char* argv[])
{
    int secs = 5;
    std::cout << "setting alarm for 5 seconds..." << std::endl;
    thread_alarm alarm(secs);
    boost::thread thrd(alarm);
    thrd.join();
}

I built two versions, one including boost\libs\thread\src\tss.cpp and
one without. Both linking to

boost\bin.v2\libs\thread\build\qcc\release\link-static\threading-multi\l
ibboost_thread-mt-1_34_1.a

and QNX 6.3's
        libcxa.a
        libcpp.a

The QNX versions of this Boost library was build using the bjam call:

        bjam -a --without-python --toolset=qcc release threading=multi
link=static

When I execute the binary without tss.cpp it crashes at runtime; the
other doesn't:

# ./BoostThreadExample
Memory fault (core dumped)

# ./BoostThreadExample_working
setting alarm for 5 seconds...
alarm sounded...

What were I doing wrong and where? My windows target of the same code
with MinGW there are no such problems.
Am I missing a static library from QNX? I tried to switch to libstdc++.a
but had no success.

Florian

> -------- Original Message --------
> Subject: Re: [Threads-devel] Static build on darwin
> Date: Tue, 12 Feb 2008 09:17:43 +0000
> From: Anthony Williams <anthony_at_[hidden]>
> Reply-To: Discussions about the boost.thread library
> <threads-devel_at_[hidden]>
> To: threads-devel_at_[hidden]
> References: <F854F4F7-D9A2-4941-A4B8-8D5FC189A71E_at_[hidden]>
>
> Quoting Thomas Hauk <thauk_at_[hidden]>:
>
> > I'm having trouble with using Boost.Thread (1.34.1) on Mac OS X
> > (10.4.11/ppc/Xcode 2.3).
>
> You might get more help on the main boost list, but I'll try
> and answer your question here.
>
> > Which makes me wonder if somehow this .a file is really a .dylib.
>
> Possibly, I know next-to-nothing about MacOS development.
>
> > What's also strange is that although the build directories
> for all the
> > other libraries have the same structure (e.g. filesystem/build/
> > darwin/debug/link-static/libboost_filesystem-d-1_34_1.a),
> the thread
> > directory has a threading-multi directory under the link-static
> > directory (meaning the file I am trying to link to is in
> thread/build/
> >
> darwin/debug/link-static/threading-multi/libboost_thread-mt-d-
> 1_34_1.a).
>
> The extra directories come from non-default settings.
> link=dynamic is default, so link=static results in an extra
> directory. Likewise for threading=multi. Obviously,
> boost.thread only compiles with threading=multi, but it's
> still not the default for the build system as a whole.
>
> > Also: is there any plan to distribute the Boost libraries
> for Mac OS X
> > in a similar way to how they are distributed for Windows (i.e.
> > installer that has pre-built library binaries)?
>
> That's definitely a question for the main boost list. Boost
> Consulting provide the pre-built binaries, so it might be
> worth asking them.
>
> Anthony
> --
> Anthony Williams | Just Software Solutions Ltd
> Custom Software Development | http://www.justsoftwaresolutions.co.uk
> Registered in England, Company Number 5478976.
> Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
>
>
> _______________________________________________
> threads-devel mailing list
> threads-devel_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/threads-devel


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk