This fixes an issue that prevented bitcoind to cross build.
CMake analyses the compiler to extract a library path, which conflicts
with the path from the depends/ directory.
This issue depends on the installed compiler, so it may not appear on
every system. I got the issue with Ubuntu 18.04 (WSL).
Details
- Reviewers
deadalnix - Group Reviewers
Restricted Project
Prerequisite:
Follow the doc/build-windows.md and depends/README.md documentation
and install the dependencies for i686-w64-mingw32 and
x86_64-w64-mingw32.
# 32-bit version mkdir buildcmake && cd buildcmake cmake -GNinja .. -DBUILD_BITCOIN_SEEDER=OFF \ -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Win32.cmake ninja
Check the build succeeds.
To run the generated src/bitcoind.exe binary some dll files need to be
copied. The files are moved to a target repository <dir>. The
installed i686-w64-mingw32 version number is <mingw-ver>. The
version number can be obtained with i686-w64-mingw32-c++ --version
(7.3 on my WSL Ubuntu 18.04).
mkdir -p <dir> cp src/bitcoind.exe <dir> cp /usr/i686-w64-mingw32/lib/libwinpthread-1.dll <dir> cp /usr/lib/gcc/i686-w64-mingw32/<mingw-ver>-posix/libstdc++-6.dll <dir> cp /usr/lib/gcc/i686-w64-mingw32/<mingw-ver>-posix/libgcc_s_sjlj-1.dll <dir>
Operate the same for Win64.
# 64-bit version rm -rf * cmake -GNinja .. -DBUILD_BITCOIN_SEEDER=OFF \ -DCMAKE_TOOLCHAIN_FILE=../cmake/platforms/Win64.cmake ninja
Check the build succeeds.
To run the generated src/bitcoind.exe binary some dll files need to be
copied. The files are moved to a target repository <dir>. The
installed x86_64-w64-mingw32 version number is <mingw-ver>. The
version number can be obtained with x86_64-w64-mingw32-c++ --version
(7.3 on my WSL Ubuntu 18.04).
mkdir -p <dir> cp src/bitcoind.exe <dir> cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll <dir> cp /usr/lib/gcc/x86_64-w64-mingw32/<mingw-ver>-posix/libstdc++-6.dll <dir> cp /usr/lib/gcc/x86_64-w64-mingw32/<mingw-ver>-posix/libgcc_s_seh-1.dll <dir>
Diff Detail
- Repository
- rABC Bitcoin ABC
- Branch
- cmake_windows_bitcoind
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 5172 Build 8407: Bitcoin ABC Buildbot (legacy) Build 8406: arc lint + arc unit
Event Timeline
src/CMakeLists.txt | ||
---|---|---|
31 | Remove what ? |
This diff removed the compiler lib path from the project lib path to avoid linking win32 version of the libstdc++ while the posix version is expected.
This can be fixed at a system configuration level by specifying to use g++ posix version *AND* gcc posix version. This makes a much cleaner solution so this patch can be avoided.
Autotools did not require to set the gcc version to posix, but didn't add the compiler lib path to the project lib path, thus avoiding the issue.