Boost C++ Libraries: Ticket #4878: MinGW 4.5.0 undefined reference to bool interruptible_wait(detail::win32::handle handle_to_wait_for,detail::t imeout target_time) https://svn.boost.org/trac10/ticket/4878 <p> test.cpp: </p> <pre class="wiki">#include &lt;boost/thread.hpp&gt; int main() { boost::this_thread::sleep( boost::get_system_time() + boost::posix_time::milliseconds(50) ); } </pre><pre class="wiki">g++ -lboost_thread-mt: In file included from C:/boost/include/boost-1_45_0/boost/thread/win32/thread_data.hpp:12:0, from C:/boost/include/boost-1_45_0/boost/thread/thread.hpp:15, from C:/boost/include/boost-1_45_0/boost/thread.hpp:13, from test.cpp:8: C:/boost/include/boost-1_45_0/boost/thread/win32/thread_heap_alloc.hpp:59:40: warning: inline function 'void* boost::detail::allocate_raw_heap_memory(unsigned int)' declared as dllimport: attribute ignored C:/boost/include/boost-1_45_0/boost/thread/win32/thread_heap_alloc.hpp:69:39: warning: inline function 'void boost::detail::free_raw_heap_memory(void*)' declared as dllimport: attribute ignored c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line. This should work unless it involves constant data structures referencing symbols from auto-imported DLLs. C:\DOCUME~1\ADMINI~1\USTAWI~1\Temp\ccW8Zsal.o:test.cpp:(.text$_ZN5boost11this_thread18interruptible_waitERKNS_10posix_time5ptimeE[boost::this_thread::interruptible_wait(boost::posix_time::ptime const&amp;)]+0x37): undefined reference to `_imp___ZN5boost11this_thread18interruptible_waitEPvNS_6detail7timeoutE' collect2: ld returned 1 exit status </pre><p> I have fixed this, but I do not know, if it is the right way: boost/thread/detail/config.hpp line 40: </p> <pre class="wiki"># if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) || \ ( __GNUC__ &gt;= 4 &amp;&amp; __GNUC_MINOR &gt;= 5 ) </pre><p> This fix gets rid of the link error, and the earlier warning. </p> <p> Cheers </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4878 Trac 1.4.3 Hendricks266@… Sun, 19 Dec 2010 22:15:53 GMT <link>https://svn.boost.org/trac10/ticket/4878#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:1</guid> <description> <p> I'm getting the same error, with MinGW32 4.5.0 and Boost from trunk, but the change to boost/thread/detail/config.hpp did not fix the problem. </p> <pre class="wiki">.cpp:(.text$_ZN5boost11this_thread18interruptible_waitEm[boost::this_thread::interruptible_wait(unsigned long)]+0x40): undefined reference to `_imp___ZN5boost11this_thread18interruptible_waitEPvNS_6detail7timeoutE' collect2: ld returned 1 exit status </pre> </description> <category>Ticket</category> </item> <item> <author>Krzysztof Czaiński <1czajnik@…></author> <pubDate>Mon, 20 Dec 2010 00:23:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4878#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:2</guid> <description> <p> I just looked at this line again, and I think I made a typo (missing underscores), boost/thread/detail/config.hpp line 40 is supposed to be: </p> <pre class="wiki"># if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) \ || ( __GNUC__ &gt;= 4 &amp;&amp; __GNUC_MINOR__ &gt;= 5 ) // fix for mingw-4.5 </pre><p> Regards </p> </description> <category>Ticket</category> </item> <item> <author>Hendricks266 <Hendricks266@…></author> <pubDate>Mon, 20 Dec 2010 03:16:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4878#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:3</guid> <description> <p> It works! Thank you. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Bryce Adelstein Lelbach</dc:creator> <pubDate>Mon, 20 Dec 2010 03:40:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4878#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:4</guid> <description> <p> Alright, I see why this fix is working (relevant code, aka $BOOST_ROOT/boost/thread/detail/config.hpp). </p> <pre class="wiki"> 34 #if defined(BOOST_THREAD_BUILD_DLL) //Build dll 35 #elif defined(BOOST_THREAD_BUILD_LIB) //Build lib 36 #elif defined(BOOST_THREAD_USE_DLL) //Use dll 37 #elif defined(BOOST_THREAD_USE_LIB) //Use lib 38 #else //Use default 39 # if defined(BOOST_THREAD_PLATFORM_WIN32) 40 # if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) 41 //For compilers supporting auto-tss cleanup 42 //with Boost.Threads lib, use Boost.Threads lib 43 # define BOOST_THREAD_USE_LIB 44 # else 45 //For compilers not yet supporting auto-tss cleanup 46 //with Boost.Threads lib, use Boost.Threads dll 47 # define BOOST_THREAD_USE_DLL 48 # endif 49 # else 50 # define BOOST_THREAD_USE_LIB 51 # endif 52 #endif </pre><p> I would be happy to apply a patch for this (though, a more versatile patch: Hendricks seemed to indicate on IRC that this is not just a problem for mingw 4.5, but a problem for mingw in general, so any mingw version should be detected, if this is in fact the right fix), but first I need to see some justification for this solution. If someone is interested in doing a little more investigating, read on and post your findings here. </p> <p> It seems that the Boost.Threads dll is not working with mingw. The comments from the above snippet seem to indicate that the Boost.Threads lib should be used for compilers supporting auto-tss cleanup. Does mingw support auto-tss cleanup? (cite sources, please). </p> <p> More importantly, it looks like the underlying problem might be that BOOST_THREAD_PLATFORM_WIN32 appears to be defined for mingw. Why is this happening (please check the Boost.Thread / Boost.Config source code, and find out where BOOST_THREAD_PLATFORM_WIN32 is being defined)? Is it an error? If BOOST_THREAD_PLATFORM_WIN32 wasn't defined, it looks like BOOST_THREAD_USE_LIB would be selected. Would this fix the mingw problem? </p> <p> Also, this needs to be tested - e.g. someone with this fix applied needs to run the Boost.Thread test suite on GCC Linux and mingw. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Bryce Adelstein Lelbach</dc:creator> <pubDate>Mon, 20 Dec 2010 03:41:27 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/4878#comment:5 https://svn.boost.org/trac10/ticket/4878#comment:5 <ul> <li><strong>cc</strong> <span class="trac-author">admin@…</span> added </li> </ul> Ticket Hendricks266 <Hendricks266@…> Mon, 20 Dec 2010 04:11:45 GMT <link>https://svn.boost.org/trac10/ticket/4878#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:6</guid> <description> <p> It appears that this bug was "fixed" before: <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4614" title="#4614: Bugs: Unable to statically link thread lib on mingw/win32 (closed: fixed)">#4614</a> </p> <p> --Side Note-- </p> <p> In bug <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4614" title="#4614: Bugs: Unable to statically link thread lib on mingw/win32 (closed: fixed)">#4614</a>, reference is made to this bug <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4315" title="#4315: Patches: gcc 4.4 Warning: inline ... declared as dllimport: attribute ignored (closed: fixed)">#4315</a>. I got these warnings as well. </p> <p> --End Side Note-- </p> <p> I can't find any information regarding auto-tss cleanup in MinGW or GCC. If tss is an acronym for "thread stack size", a web search of [auto thread stack size cleanup site:gnu.org] may be on the right track. </p> <p> Here's the MinGW-encompassing modification: </p> <pre class="wiki"># if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) || defined(__MINGW32__) || defined(MINGW32) || defined(BOOST_MINGW32) </pre><p> Relevant link: <a class="ext-link" href="http://redmine.webtoolkit.eu/projects/wt/wiki/Installing_Wt_on_MinGW"><span class="icon">​</span>http://redmine.webtoolkit.eu/projects/wt/wiki/Installing_Wt_on_MinGW</a> </p> <p> On the BOOST_THREAD_PLATFORM_WIN32 front, this is $BOOST_ROOT/boost/thread/detail/platform.hpp: </p> <pre class="wiki">// fetch compiler and platform configuration #include &lt;boost/config.hpp&gt; // insist on threading support being available: #include &lt;boost/config/requires_threads.hpp&gt; // choose platform #if defined(linux) || defined(__linux) || defined(__linux__) # define BOOST_THREAD_LINUX #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) # define BOOST_THREAD_BSD #elif defined(sun) || defined(__sun) # define BOOST_THREAD_SOLARIS #elif defined(__sgi) # define BOOST_THREAD_IRIX #elif defined(__hpux) # define BOOST_THREAD_HPUX #elif defined(__CYGWIN__) # define BOOST_THREAD_CYGWIN #elif (defined(_WIN32) || defined(__WIN32__) || defined(WIN32)) &amp;&amp; !defined(BOOST_DISABLE_WIN32) # define BOOST_THREAD_WIN32 #elif defined(__BEOS__) # define BOOST_THREAD_BEOS #elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__) # define BOOST_THREAD_MACOS #elif defined(__IBMCPP__) || defined(_AIX) # define BOOST_THREAD_AIX #elif defined(__amigaos__) # define BOOST_THREAD_AMIGAOS #elif defined(__QNXNTO__) # define BOOST_THREAD_QNXNTO #elif defined(unix) || defined(__unix) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) # if defined(BOOST_HAS_PTHREADS) &amp;&amp; !defined(BOOST_THREAD_POSIX) # define BOOST_THREAD_POSIX # endif #endif // For every supported platform add a new entry into the dispatch table below. // BOOST_THREAD_POSIX is tested first, so on platforms where posix and native // threading is available, the user may choose, by defining BOOST_THREAD_POSIX // in her source. If a platform is known to support pthreads and no native // port of boost_thread is available just specify "pthread" in the // dispatcher table. If there is no entry for a platform but pthreads is // available on the platform, pthread is choosen as default. If nothing is // available the preprocessor will fail with a diagnostic message. #if defined(BOOST_THREAD_POSIX) # define BOOST_THREAD_PLATFORM_PTHREAD #else # if defined(BOOST_THREAD_WIN32) # define BOOST_THREAD_PLATFORM_WIN32 # elif defined(BOOST_HAS_PTHREADS) # define BOOST_THREAD_PLATFORM_PTHREAD # else # error "Sorry, no boost threads are available for this platform." # endif #endif </pre><p> WIN32 appears to go all the way to the base of Boost. </p> <p> I would be willing to run the Boost.Thread test suite on MinGW. How do I run it? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 08 Feb 2012 22:10:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4878#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:7</guid> <description> <p> Go to libs/thread/test and do </p> <p> bjam toolset=&lt;name as defined on your user-config.jam&gt; </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 15 Aug 2012 21:02:22 GMT</pubDate> <title>description changed https://svn.boost.org/trac10/ticket/4878#comment:8 https://svn.boost.org/trac10/ticket/4878#comment:8 <ul> <li><strong>description</strong> modified (<a href="/trac10/ticket/4878?action=diff&amp;version=8">diff</a>) </li> </ul> Ticket viboes Wed, 15 Aug 2012 21:18:52 GMT <link>https://svn.boost.org/trac10/ticket/4878#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:9</guid> <description> <p> Could you show the failing command line? Have you tried adding --enable-auto-import to the command line as suggested by the error message? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 17 Feb 2013 17:28:29 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4878#comment:10 https://svn.boost.org/trac10/ticket/4878#comment:10 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> <p> This is working for me. Please open it if you have problems on trunk (or 1.53). </p> Ticket Kevin Brightwell <kevin.brightwell2@…> Tue, 02 Apr 2013 15:21:44 GMT <link>https://svn.boost.org/trac10/ticket/4878#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:11</guid> <description> <p> I encountered this error using Boost 1.53.0 on MinGW 4.7 on Windows 7. </p> <p> I applied the following at line 318 in <code>boost\thread\detail\config.hpp</code> </p> <pre class="wiki">#if defined(BOOST_THREAD_BUILD_DLL) //Build dll #elif defined(BOOST_THREAD_BUILD_LIB) //Build lib #elif defined(BOOST_THREAD_USE_DLL) //Use dll #elif defined(BOOST_THREAD_USE_LIB) //Use lib #else //Use default # if defined(BOOST_THREAD_PLATFORM_WIN32) # if defined(BOOST_MSVC) || defined(BOOST_INTEL_WIN) \ || defined(__MINGW32__) || defined(MINGW32) || defined(BOOST_MINGW32) //For compilers supporting auto-tss cleanup //with Boost.Threads lib, use Boost.Threads lib # define BOOST_THREAD_USE_LIB # else //For compilers not yet supporting auto-tss cleanup //with Boost.Threads lib, use Boost.Threads dll # define BOOST_THREAD_USE_DLL # endif # else # define BOOST_THREAD_USE_LIB # endif #endif </pre><p> This is the exact solution from: <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/4878#comment:6"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/4878#comment:6</a> </p> </description> <category>Ticket</category> </item> <item> <author>Kevin Brightwell <kevin.brightwell2@…></author> <pubDate>Tue, 02 Apr 2013 15:26:10 GMT</pubDate> <title>cc, status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/4878#comment:12 https://svn.boost.org/trac10/ticket/4878#comment:12 <ul> <li><strong>cc</strong> <span class="trac-author">kevin.brightwell2@…</span> added </li> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.45.0</span> → <span class="trac-field-new">Boost 1.53.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">worksforme</span> </li> </ul> Ticket viboes Sun, 07 Apr 2013 22:25:56 GMT <link>https://svn.boost.org/trac10/ticket/4878#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:13</guid> <description> <blockquote> <p> Changeset <a class="changeset" href="https://svn.boost.org/trac10/changeset/83796" title="Thread: rollback BOOST_THREAD_PROVIDES_ONCE_CXX11 define. Force minwg ...">[83796]</a> </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 08 Apr 2013 17:27:06 GMT</pubDate> <title>owner, status, milestone changed https://svn.boost.org/trac10/ticket/4878#comment:14 https://svn.boost.org/trac10/ticket/4878#comment:14 <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">reopened</span> → <span class="trac-field-new">new</span> </li> <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> Merge from trunk <a class="changeset" href="https://svn.boost.org/trac10/changeset/83811" title="Thread: merge from trunk 1.54: Added lambda tests, refactored ...">[83811]</a>. </p> Ticket viboes Mon, 08 Apr 2013 17:27:27 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4878#comment:15 https://svn.boost.org/trac10/ticket/4878#comment:15 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket anonymous Tue, 25 Jun 2013 10:41:53 GMT <link>https://svn.boost.org/trac10/ticket/4878#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4878#comment:16</guid> <description> <p> I also encountered this error while using Boost 1.53.0 on MinGW 4.7.2 on Windows 7. (on Jun 2013) </p> <p> I applied the fix as listed by Kevin Brightwell at line 318 in boost\thread\detail\config.hpp </p> <p> I thought this was fixed 3 months ago? </p> </description> <category>Ticket</category> </item> </channel> </rss>