Boost logo

Boost :

From: Jorge Lodos (lodos_at_[hidden])
Date: 2005-08-11 12:17:44


Hi

I'm trying to use the the boost::thread::mutex class in a Windows 95
project. Since the generated .lib files for the thread library include
InterlockedCompareExchange (used in try_mutex::call_once) I was left with
the option of adding the mutex.cpp and the exceptions.cpp files to my
project and compiling them separately.

Building the program included at the end, MSCV 7.1 gives the following
linker errors:

Compiling...

Mutex.cpp

Linking...

mutex1.obj : error LNK2019: unresolved external symbol "void __cdecl
boost::call_once(void (__cdecl*)(void),long &)"
(?call_once_at_boost@@YAXP6AXXZAAJ_at_Z) referenced in function "bool __cdecl
`anonymous namespace'::has_TryEnterCriticalSection(void)"
(?has_TryEnterCriticalSection@?A0x5deb84cd@@YA_NXZ)

mutex1.obj : error LNK2019: unresolved external symbol "int __cdecl
boost::xtime_get(struct boost::xtime *,int)"
(?xtime_get_at_boost@@YAHPAUxtime_at_1@H_at_Z) referenced in function "private: bool
__thiscall boost::timed_mutex::do_timedlock(struct boost::xtime const &)"
(?do_timedlock_at_timed_mutex_at_boost@@AAE_NABUxtime_at_2@@Z)

Debug/Mutex.exe : fatal error LNK1120: 2 unresolved externals

 

call_once is called in try_mutex constructor, while xtime_get is called in
timed_mutex::do_timedlock.

Nor try_mutex or timed_mutex are used at all. This was confirmed by
commenting out the whole implementation for both in mutex.cpp, in which case
the program links without problems.

Just commenting out the lines m_critical_section =
has_TryEnterCriticalSection(); in the try_mutex constructor and
boost::xtime_get(&cur, boost::TIME_UTC); in timed_mutex::do_timedlock makes
the program link.

I originally expected the linker will remove all try_mutex and timed_muted
implementation but it does not.

Can someone give any ideas on how to use boost::mutex in a MSCV 7.1 project
for Windows 95 without having to modify the original files? Is there a
reason for the linker not to remove all the code for try_mutex and
timed_mutex?

Thanks in advance.

 

Best regards

Jorge

 

 

#define BOOST_THREAD_NO_LIB

#include <boost/thread/mutex.hpp>

 

// mutex.cpp and exceptions.cpp compiled with

// BOOST_THREAD_NO_LIB preprocessor option.

// This must be enforced, since they both #include

// <boost/thread/detail/config.hpp>

 

int main(int argc, char *argv[ ])

{

      boost::mutex mymutex;

      boost::mutex::scoped_lock scoped_lock(mymutex);

}


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