Boost logo

Boost :

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


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:




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)"

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 &)"

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


call_once is called in try_mutex constructor, while xtime_get is called in

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

Thanks in advance.


Best regards





#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, gregod at, cpdaniel at, john at