[thread] Trying to cross build 1.64.0 boost.thread with mingw posix threads

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

[thread] Trying to cross build 1.64.0 boost.thread with mingw posix threads

Boost - Dev mailing list

I built a w64 cross-compiler to make windows binaries on linux. The
cross-compiler has Posix threads, not win32 threads. I would like to
build boost.thread with it but I have some difficulties:

1. I do not need to link with any library to build applications with
C++11 threads but boost build asks for PTW32_INCLUDE and PTW32_LIB
otherwise it sets <build>no so that the library is not built. This is
easily changed with the following patch:

diff -r -u boost_1_64_0-0/libs/thread/build/Jamfile.v2
--- boost_1_64_0-0/libs/thread/build/Jamfile.v2 2017-04-17
04:22:25.000000000 +0200
+++ boost_1_64_0-1/libs/thread/build/Jamfile.v2 2017-07-12
14:24:03.960979687 +0200
@@ -271,10 +271,6 @@
                result += $(paths) ;
-            else
-            {
-                result = <build>no ;
-            }
        result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
        if ! [ configure.builds has_atomic_flag_lockfree

2. Once this patch is applied, the library is built but there are
errors when compiling libs/thread/src/pthread/thread.cpp. The command
that is run by b2 is given below. Here are the errors:
libs/thread/src/pthread/thread.cpp:541:2: error: #error
In file included from ./boost/thread/thread_only.hpp:17:0,
                from libs/thread/src/pthread/thread.cpp:11:
./boost/thread/pthread/thread_data.hpp: In member function ‘void
./boost/thread/pthread/thread_data.hpp:53:35: error: ‘getpagesize’ was
not declared in this scope
          std::size_t page_size = getpagesize();

The first error is because apparently neither BOOST_HAS_SCHED_YIELD

I understand that the 2nd error comes from the fact that getpagesize()
is not in unistd.h provided by mingw-w64.

There is a strange thing about the command line: it contains -mthreads
although I never provided it. I tried to remove it or replace it with
-pthread or -lptread but I still get the same error message.

"i686-w64-mingw32-g++-7.1.0"  -ftemplate-depth-128 -std=c++14 -O2
-DNDEBUG -O3 -finline-functions -Wno-inline -Wall -pedantic
-march=i686 -mthreads -m32 -Wextra -Wno-long-long
-Wno-unused-parameter -Wunused-function -pedantic -DBOOST_ALL_NO_LIB=1

Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost