Boost C++ Libraries: Ticket #7980: Build error: msvc-11.0 and BOOST_THREAD_DONT_USE_DATETIME https://svn.boost.org/trac10/ticket/7980 <p> Hi, </p> <p> I'm getting the following build error using msvc-11.0 with BOOST_THREAD_DONT_USE_DATETIME defined. </p> <pre class="wiki">compile-c-c++ bin.v2\libs\thread\build\msvc-11.0\debug\address-model-64\debug-symbols-off\link-static\runtime-link-static\threading-multi\win32\thread.obj thread.cpp .\boost/thread/win32/shared_mutex.hpp(136) : error C3861: 'timed_lock_shared': identifier not found .\boost/thread/future.hpp(354) : warning C4913: user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86_amd64 &gt;nul cl /Zm800 -nologo @"bin.v2\libs\thread\build\msvc-11.0\debug\address-model-64\debug-symbols-off\link-static\runtime-link-static\threading-multi\win32\thread.obj.rsp" ...failed compile-c-c++ bin.v2\libs\thread\build\msvc-11.0\debug\address-model-64\debug-symbols-off\link-static\runtime-link-static\threading-multi\win32\thread.obj... ...skipped &lt;pbin.v2\libs\thread\build\msvc-11.0\debug\address-model-64\debug-symbols-off\link-static\runtime-link-static\threading-multi&gt;libboost_thread-vc110-mt-sgd-1_53.lib for lack of &lt;pbin.v2\libs\thread\build\msvc-11.0\debug\address-model-64\debug-symbols-off\link-static\runtime-link-static\threading-multi&gt;win32\thread.obj... ...skipped &lt;pd:\Working\lib64&gt;libboost_thread-vc110-mt-sgd-1_53.lib for lack of &lt;pbin.v2\libs\thread\build\msvc-11.0\debug\address-model-64\debug-symbols-off\link-static\runtime-link-static\threading-multi&gt;libboost_thread-vc110-mt-sgd-1_53.lib... ...failed updating 1 target... ...skipped 2 targets... </pre><p> My full command line is as follows: </p> <pre class="wiki">b2 -j 4 toolset=msvc-11.0 address-model=64 --with-thread --with-timer --prefix=D:\Boost --libdir=%CD%\lib64 threading=multi link=static runtime-link=static variant=debug debug-symbols=off define=_CRT_SECURE_NO_WARNINGS=1 define=_SCL_SECURE_NO_WARNINGS=1 define=_CRT_NON_CONFORMING_SWPRINTFS define=BOOST_THREAD_DONT_USE_DATETIME install </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7980 Trac 1.4.3 viboes Tue, 05 Feb 2013 21:46:47 GMT owner, status changed https://svn.boost.org/trac10/ticket/7980#comment:1 https://svn.boost.org/trac10/ticket/7980#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Waiting for a fix, maybe you could try defining BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN. </p> Ticket viboes Tue, 05 Feb 2013 21:59:19 GMT <link>https://svn.boost.org/trac10/ticket/7980#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7980#comment:2</guid> <description> <p> Does this patch fixes the issue? </p> <pre class="wiki">svn diff ../../../boost/thread/win32/shared_mutex.hpp Index: ../../../boost/thread/win32/shared_mutex.hpp =================================================================== --- ../../../boost/thread/win32/shared_mutex.hpp (revision 82706) +++ ../../../boost/thread/win32/shared_mutex.hpp (working copy) @@ -133,7 +133,11 @@ void lock_shared() { +#if defined BOOST_THREAD_USES_DATETIME BOOST_VERIFY(timed_lock_shared(::boost::detail::get_system_time_sentinel())); +#else + BOOST_VERIFY(try_lock_shared_until(chrono::steady_clock::now())); +#endif } #if defined BOOST_THREAD_USES_DATETIME @@ -379,14 +383,20 @@ void lock() { +#if defined BOOST_THREAD_USES_DATETIME BOOST_VERIFY(timed_lock(::boost::detail::get_system_time_sentinel())); +#else + BOOST_VERIFY(try_lock_until(chrono::steady_clock::now())); +#endif } +#if defined BOOST_THREAD_USES_DATETIME template&lt;typename TimeDuration&gt; bool timed_lock(TimeDuration const &amp; relative_time) { return timed_lock(get_system_time()+relative_time); } +#endif bool try_lock() { @@ -414,6 +424,7 @@ } +#if defined BOOST_THREAD_USES_DATETIME bool timed_lock(boost::system_time const&amp; wait_until) { for(;;) @@ -492,7 +503,7 @@ BOOST_ASSERT(wait_res&lt;2); } } - +#endif #ifdef BOOST_THREAD_USES_CHRONO template &lt;class Rep, class Period&gt; bool try_lock_for(const chrono::duration&lt;Rep, Period&gt;&amp; rel_time) </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 06 Feb 2013 09:55:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7980#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7980#comment:3</guid> <description> <p> Not quite. </p> <p> It now complains about: </p> <pre class="wiki">compile-c-c++ bin.v2\libs\thread\build\msvc-11.0\release\address-model-64\debug-store-database\debug-symbols-on\link-static\runtime-link-static\threading-multi\win32\thread.obj thread.cpp D:\boost_1_53_0\boost/thread/win32/shared_mutex.hpp(139) : error C2653: 'chrono' : is not a class or namespace name D:\boost_1_53_0\boost/thread/win32/shared_mutex.hpp(139) : error C3861: 'try_lock_shared_until': identifier not found D:\boost_1_53_0\boost/thread/win32/shared_mutex.hpp(139) : error C3861: 'now': identifier not found D:\boost_1_53_0\boost/thread/win32/shared_mutex.hpp(389) : error C2653: 'chrono' : is not a class or namespace name D:\boost_1_53_0\boost/thread/win32/shared_mutex.hpp(389) : error C3861: 'try_lock_until': identifier not found D:\boost_1_53_0\boost/thread/win32/shared_mutex.hpp(389) : error C3861: 'now': identifier not found D:\boost_1_53_0\boost/thread/future.hpp(354) : warning C4913: user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used </pre><p> I'll qualify those uses of <code>chrono</code> with <code>::boost::</code> and post back with the result. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 06 Feb 2013 10:46:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7980#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7980#comment:4</guid> <description> <p> Ah... Other uses of <code>chrono::steady_clock</code> seem to be wrapped in <code>BOOST_THREAD_USES_CHRONO</code>. With the patch applied if I add <code>define=BOOST_THREAD_USES_CHRONO</code> to the build command it builds. </p> <p> It seems I need both the patch <em>and</em> <code>define=BOOST_THREAD_USES_CHRONO</code>. One or other alone doesn't fix the build. </p> <p> I hope that's useful. </p> <p> P.S. Just FYI, without the patch but with <code>define=BOOST_THREAD_USES_CHRONO</code> I get: </p> <pre class="wiki">compile-c-c++ bin.v2\libs\thread\build\msvc-11.0\release\address-model-32\debug-store-database\debug-symbols-on\link-static\runtime-link-static\threading-multi\win32\thread.obj thread.cpp D:\boost_1_53_0\boost/thread/win32/shared_mutex.hpp(136) : error C3861: 'timed_lock_shared': identifier not found D:\boost_1_53_0\boost/thread/future.hpp(354) : warning C4913: user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 07 Feb 2013 18:33:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7980#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7980#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7980#comment:4" title="Comment 4">anonymous</a>: </p> <blockquote class="citation"> <p> Ah... Other uses of <code>chrono::steady_clock</code> seem to be wrapped in <code>BOOST_THREAD_USES_CHRONO</code>. With the patch applied if I add <code>define=BOOST_THREAD_USES_CHRONO</code> to the build command it builds. </p> </blockquote> <p> I guess I see from where the problem comes from. The Jamfile in thread/build defines BOOST_THREAD_DONT_USE_CHRONO. I have made some changes in trunk lastly (pthread part) to ensure that shared_mutex.hpp is not used when thread.cpp is compiled. I plan to do the same for the win32 part, so you should not need to add the define explicitly. </p> <p> Thanks for this report. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 07 Feb 2013 18:38:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7980#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7980#comment:6</guid> <description> <p> If you are using the trunk or if you apply the modification introduced in <a class="changeset" href="https://svn.boost.org/trac10/changeset/82757" title="Thread: make the pthread binary to don't depend on shared_mutex.hpp + ...">[82757]</a> and add the following patch </p> <pre class="wiki">svn diff win32/thread.cpp Index: win32/thread.cpp =================================================================== --- win32/thread.cpp (revision 82706) +++ win32/thread.cpp (working copy) @@ -14,7 +14,7 @@ #endif //#define BOOST_THREAD_VERSION 3 -#include &lt;boost/thread/thread.hpp&gt; +#include &lt;boost/thread/thread_only.hpp&gt; #include &lt;boost/thread/once.hpp&gt; </pre><p> Does it works without define=BOOST_THREAD_USES_CHRONO? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 07 Feb 2013 18:44:34 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/7980#comment:7 https://svn.boost.org/trac10/ticket/7980#comment:7 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> <p> Committed in trunk revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/82777" title="Thread: manage #7980">[82777]</a>. </p> Ticket anonymous Fri, 08 Feb 2013 15:38:39 GMT <link>https://svn.boost.org/trac10/ticket/7980#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7980#comment:8</guid> <description> <p> Starting with official 1_53_0 release. I applied the 82757 patch. </p> <pre class="wiki">$ patch.exe -p 2 -i changeset_82757.diff patching file boost/thread/thread.hpp patching file boost/thread/thread_only.hpp patching file boost/thread/future.hpp patching file libs/thread/src/pthread/thread.cpp Hunk #1 succeeded at 10 (offset 1 line). Hunk #2 succeeded at 437 (offset 1 line). </pre><p> I then applied the 82777 patch. </p> <pre class="wiki">$ patch.exe -p 2 -i changeset_82777.diff patching file boost/thread/win32/shared_mutex.hpp patching file libs/thread/src/win32/thread.cpp </pre><p> I then built <em>without</em> <code>define=BOOST_THREAD_USES_CHRONO</code>, and ... it built! </p> <p> I've not tried linking to the built libraries yet, but I'm sure it will be fine. </p> <p> Thanks for all your help. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 13 Feb 2013 06:44:07 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7980#comment:9 https://svn.boost.org/trac10/ticket/7980#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Merged <a class="changeset" href="https://svn.boost.org/trac10/changeset/82838" title="Thread: merge from trunk 1.54 - once_atomic; null_mutex">[82838]</a> </p> Ticket