Skip to content

Commit 4db3dcf

Browse files
committed
Fix Windows link: provide boost::throw_exception shim for Boost 1.90
Boost 1.90 on MSVC declares throw_exception in a header but the Conan package may not include the compiled library. Provide our own implementation (guarded by BOOST_VERSION >= 109000) so the symbol resolves on all platforms without depending on package manager config.
1 parent 58aa6c2 commit 4db3dcf

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ set(source
3333
address_utils.hpp address_utils.cpp
3434
leveldb_store.hpp leveldb_store.cpp
3535
address_validator.hpp address_validator.cpp
36+
boost_throw_exception.cpp
3637
)
3738

3839
find_package(yaml-cpp REQUIRED)
3940

4041
add_library(core STATIC ${source})
4142
target_link_libraries(core btclibs)
4243

43-
target_link_libraries(core Boost::headers Boost::log Boost::log_setup Boost::thread Boost::filesystem Boost::exception yaml-cpp nlohmann_json::nlohmann_json ${LEVELDB_LIBRARIES})
44+
target_link_libraries(core Boost::headers Boost::log Boost::log_setup Boost::thread Boost::filesystem yaml-cpp nlohmann_json::nlohmann_json ${LEVELDB_LIBRARIES})
4445

4546
# Add LevelDB include directories
4647
target_include_directories(core PUBLIC ${LEVELDB_INCLUDE_DIRS})

src/core/boost_throw_exception.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Provide boost::throw_exception implementation for Boost 1.90+ on MSVC.
2+
// Boost 1.90 declares throw_exception in a header but the compiled library
3+
// may not be available in all package manager configurations (Conan/vcpkg).
4+
// This shim ensures the symbol is always resolvable.
5+
#include <boost/version.hpp>
6+
#if BOOST_VERSION >= 109000
7+
#include <boost/config.hpp>
8+
#include <boost/throw_exception.hpp>
9+
#include <boost/exception/exception.hpp>
10+
11+
#if !defined(BOOST_NO_EXCEPTIONS)
12+
namespace boost {
13+
BOOST_NORETURN void throw_exception(std::exception const& e) {
14+
throw e;
15+
}
16+
BOOST_NORETURN void throw_exception(std::exception const& e,
17+
boost::source_location const&) {
18+
throw e;
19+
}
20+
} // namespace boost
21+
#endif
22+
#endif

0 commit comments

Comments
 (0)