Boost logo

Boost :

From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2007-08-02 18:09:34


On 8/2/07, Joaquin M Lopez Munoz <joaquin_at_[hidden]> wrote:
>
>
> Hello Caleb, thank you for trying the preview and for your contributions!
> When you say you multithreading it's needed in Linux: what behavior do
> you observe otherwise? Also, could you provide me with the Linux
> version and compiler you're using?

I'm using gcc-4.1.3 on Debian/unstable.

Without the <threading>multi, the gcc.link step fails for ip_allocator due
to unresolved externals:

gcc.link ../../../bin.v2/libs/multi_index/example/gcc-4.1.3
/debug/ip_allocator
../../../bin.v2/libs/multi_index/example/gcc-4.1.3/debug/ip_allocator.o: In
function `mutexattr_wrapper':
/home/cae/src/boost/libs/multi_index/example/../../../boost/interprocess/sync/posix/pthread_helpers.hpp:37:
undefined reference to `pthread_mutexattr_init'
/home/cae/src/boost/libs/multi_index/example/../../../boost/interprocess/sync/posix/pthread_helpers.hpp:37:
undefined reference to `pthread_mutexattr_setpshared'
/home/cae/src/boost/libs/multi_index/example/../../../boost/interprocess/sync/posix/pthread_helpers.hpp:37:
undefined reference to `pthread_mutexattr_settype'
../../../bin.v2/libs/multi_index/example/gcc-4.1.3/debug/ip_allocator.o: In
function `~mutexattr_wrapper':
/home/cae/src/boost/libs/multi_index/example/../../../boost/interprocess/sync/posix/pthread_helpers.hpp:45:
undefined reference to `pthread_mutexattr_destroy'
../../../bin.v2/libs/multi_index/example/gcc-4.1.3/debug/ip_allocator.o: In
function
`boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t,
char const*, boost::interprocess::mode_t)':
/home/cae/src/boost/libs/multi_index/example/../../../boost/interprocess/shared_memory_object.hpp:316:
undefined reference to `shm_open'
collect2: ld returned 1 exit status

Basically unless you link an executable with -pthread on Linux, the
threading primitives are not available, and -lrt is required for the SysV
shared memory primitives. Specifying "<threading>multi" seems to achieve
both of these goals.

This could be considered to be an issue with the interprocess library, but
since it is header only and doesn't provide its own Jamfile, you can't add
"/boost/interprocess" to the dependencies, and have it puck up that
requirement AFAIK.

If you look at the Jamfile.v2 in the interprocess example directory, you'll
see it adds <threading>multi.

-- 
Caleb Epstein

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk