fix(i2p): Windows link order — i2pd archives + Boost/zlib sandwich
The linker needs to see i2pd archives, then Boost/zlib to resolve their symbols, then i2pd archives AGAIN to resolve any remaining references. Added raw -l fallbacks for MinGW where Boost:: CMake imported targets may not exist even though libs are installed.
This commit is contained in:
+30
-11
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user