Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

BOOST_HAS_PTHREADS not set with emscripten

Open
#511 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
cmake, cpp, wasm

Research direction

Start with the provided CMake FetchContent example using Boost 1.87.0 and Emscripten, then inspect the config logic that determines BOOST_HAS_PTHREADS for this compiler. Compare the resulting configuration with the Windows-specific path producing the thread_mutex.hpp errors. Done means the example configures and compiles without the __declspec errors, with the pthread capability detected correctly.

Written by the indexing model from the issue text.

Description

This looks like a regression on #402

Minimal example to reproduce with cmake:


cmake_minimum_required(VERSION 3.27)
project(boost_wasm_test)

set(CMAKE_CXX_STANDARD 20)

include(FetchContent)

FetchContent_Declare(
        Boost
        URL https://github.com/boostorg/boost/releases/download/boost-1.87.0/boost-1.87.0-cmake.7z
        EXCLUDE_FROM_ALL
)
set(BOOST_INCLUDE_LIBRARIES geometry)
FetchContent_MakeAvailable(Boost)


add_executable(boost_wasm_test main.cpp)
target_link_libraries(boost_wasm_test Boost::geometry)
target_compile_options(boost_wasm_test PRIVATE -pthread)
target_link_options(boost_wasm_test PRIVATE -pthread)

(main.cpp is just generic hello world)

I get lots of errors like

In file included from /home/m/Documents/Linos/boost_wasm_test/build_emscripten/_deps/boost-src/libs/container/src/synchronized_pool_resource.cpp:14:
/home/m/Documents/Linos/boost_wasm_test/build_emscripten/_deps/boost-src/libs/container/include/boost/container/detail/thread_mutex.hpp:109:12: error: '__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes
  109 | extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(::_RTL_CRITICAL_SECTION *);

Which indicates, that BOOST_HAS_PTHREADS is not properly set.
Or am I using CMake wrong?

I am on emscripten v3.1.61
Same result with latest emscripten 4.04

Dominant language
C++
Stars
80
Forks
184
Avg merge
4d 6h
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/config

All issues in boostorg/config

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.