Linking Error on WaitForSingleObject

Hello All,
I have a very unusual linking issue. It might be trivial but I could
not find any reference after searching on the mailing list and other
forums. I wrote a very simple example code (attached at the end of
message) for using boost lock and mutex. The same piece of code
compiles fine without linking error in one Visual Studio Project and
gives the following linking error in another Visual Studio Project. I
have made sure that the VS settings for each project match exactly.
ERROR: error LNK2019: unresolved external symbol
__imp__WaitForSingleObject__USE_VCR_MODE@8 referenced in function
"public: void __thiscall boost::detail::basic_timed_mutex::lock(void)"
(?lock@basic_timed_mutex@detail@boost@@QAEXXZ)
I am using Visual Studio 2010 and boost 1_45_0. The code is linking to
libboost_thread-vc100-mt-s-1_45.lib in both the projects. Any
suggestions on what could be the possible cause of this or how to fix
this will be highly appreciated.
Thanks,
Anish
boost::mutex active_source_mutex;
class TESTCLASS {
public:
void LOOP(int count) {
int tcount = 0;
for(int j=0; j

ERROR: error LNK2019: unresolved external symbol __imp__WaitForSingleObject__USE_VCR_MODE@8 referenced in function "public: void __thiscall boost::detail::basic_timed_mutex::lock(void)" (?lock@basic_timed_mutex@detail@boost@@QAEXXZ)
I am using Visual Studio 2010 and boost 1_45_0. The code is linking to libboost_thread-vc100-mt-s-1_45.lib in both the projects.
Maybe I'm mistaken, but it seems to me that CRT linkages of boost and your application do not match: libboost_thread-vc100-mt-s-1_45.lib -- uses static CRT __imp__WaitForSingleObject -- looks like you use /MD option in your code-generation settings, i.e. link CRT dynamically. Try to change this option to /MT.

AMDG On 1/12/2011 7:40 AM, Igor R wrote:
ERROR: error LNK2019: unresolved external symbol __imp__WaitForSingleObject__USE_VCR_MODE@8 referenced in function "public: void __thiscall boost::detail::basic_timed_mutex::lock(void)" (?lock@basic_timed_mutex@detail@boost@@QAEXXZ)
I am using Visual Studio 2010 and boost 1_45_0. The code is linking to libboost_thread-vc100-mt-s-1_45.lib in both the projects. Maybe I'm mistaken, but it seems to me that CRT linkages of boost and your application do not match: libboost_thread-vc100-mt-s-1_45.lib -- uses static CRT __imp__WaitForSingleObject -- looks like you use /MD option in your code-generation settings, i.e. link CRT dynamically. Try to change this option to /MT.
WaitForSingleObject isn't in the CRT, it's in kernel32.dll. In Christ, Steven Watanabe
participants (3)
-
Anish Chandak
-
Igor R
-
Steven Watanabe