diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c68502b..c643cdb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -234,31 +234,50 @@ if(USE_I2P_EMBEDDED) ) # i2pd builds as two static libraries: libi2pd.a (core router) and # libi2pd_client.a (SAM, SOCKS, tunnels, client context). Both are needed. - # The static libs have circular inter-dependencies. Rather than using - # --start-group/--end-group (which CMake mis-orders with Ninja), we - # list each archive twice so the linker resolves all symbols in two - # left-to-right passes. + # The static libs have circular inter-dependencies and also reference + # Boost (filesystem, program_options) and zlib symbols. On MinGW the + # Boost:: targets may not exist as CMake imported targets even though + # the libraries are installed, so we use raw -l flags as a fallback. target_link_libraries(triangles_common PUBLIC "${I2P_SOURCE_ROOT}/libi2pdclient.a" "${I2P_SOURCE_ROOT}/libi2pd.a" "${I2P_SOURCE_ROOT}/libi2pdlang.a" "${I2P_SOURCE_ROOT}/libi2pdclient.a" "${I2P_SOURCE_ROOT}/libi2pd.a" - Boost::program_options Boost::thread Boost::chrono + ) + # Boost and zlib dependencies of i2pd — these MUST come after the + # archives in link order so unresolved symbols get satisfied. + if(TARGET Boost::filesystem) + target_link_libraries(triangles_common PUBLIC Boost::filesystem) + elseif(WIN32) + target_link_libraries(triangles_common PUBLIC boost_filesystem-mt) + endif() + if(TARGET Boost::system) + target_link_libraries(triangles_common PUBLIC Boost::system) + elseif(WIN32) + target_link_libraries(triangles_common PUBLIC boost_system-mt) + endif() + if(TARGET Boost::program_options) + target_link_libraries(triangles_common PUBLIC Boost::program_options) + elseif(WIN32) + target_link_libraries(triangles_common PUBLIC boost_program_options-mt) + endif() + target_link_libraries(triangles_common PUBLIC + Boost::thread Boost::chrono OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB ) + # List the archives again after Boost/zlib so the linker can resolve + # any remaining i2pd→Boost references in a second pass. + target_link_libraries(triangles_common PUBLIC + "${I2P_SOURCE_ROOT}/libi2pd.a" + "${I2P_SOURCE_ROOT}/libi2pdclient.a" + ) if(WIN32) target_link_libraries(triangles_common PUBLIC -Wl,--allow-multiple-definition ) endif() - if(TARGET Boost::filesystem) - target_link_libraries(triangles_common PUBLIC Boost::filesystem) - endif() - if(TARGET Boost::system) - target_link_libraries(triangles_common PUBLIC Boost::system) - endif() endif() # Platform-specific libraries