From 8d97dea0b2e085ed872b2942496a55df2ec8649f Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 31 Mar 2023 11:38:49 -0400 Subject: [PATCH] build monero-java on windows using --export-all-symbols combine build script --- CMakeLists.txt | 4 ++++ README.md | 8 ++++---- bin/build_libmonero_cpp.sh | 17 +++++++++++++++-- bin/build_libmonero_cpp_dll.sh | 10 ---------- src/wallet/monero_wallet.h | 2 +- 5 files changed, 24 insertions(+), 17 deletions(-) delete mode 100644 bin/build_libmonero_cpp_dll.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index e44e24b..5355ac2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,6 +335,10 @@ if (BUILD_LIBRARY) ${EXTRA_LIBRARIES} ) +if (WIN32) + target_link_options(monero-cpp PUBLIC "-Wl,--enable-auto-import,--export-all-symbols") +endif() + INSTALL(FILES src/daemon/monero_daemon.h src/daemon/monero_daemon_model.h DESTINATION include/daemon) diff --git a/README.md b/README.md index fe48409..0be9fc7 100644 --- a/README.md +++ b/README.md @@ -211,19 +211,19 @@ For example, [monero-java](https://github.com/monero-ecosystem/monero-java) comp 1. Download and install [MSYS2](https://www.msys2.org/). 2. Press the Windows button and launch `MSYS2 MINGW64` for 64 bit systems or `MSYS2 MINGW32` for 32 bit. -3. Update packages: `pacman -Syu` and `pacman -Syy` +3. Update packages: `pacman -Syu` and confirm at prompts. 4. Relaunch MSYS2 (if necessary) and install dependencies: For 64 bit: ``` - pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-unbound mingw-w64-x86_64-protobuf git mingw-w64-x86_64-libusb make gettext base-devel + pacman -S mingw-w64-x86_64-toolchain make mingw-w64-x86_64-cmake mingw-w64-x86_64-boost mingw-w64-x86_64-openssl mingw-w64-x86_64-zeromq mingw-w64-x86_64-libsodium mingw-w64-x86_64-hidapi mingw-w64-x86_64-unbound mingw-w64-x86_64-protobuf git mingw-w64-x86_64-libusb gettext base-devel ``` For 32 bit: ``` - pacman -S mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-zeromq mingw-w64-i686-libsodium mingw-w64-i686-hidapi mingw-w64-i686-unbound mingw-w64-i686-protobuf git mingw-w64-i686-libusb make gettext base-devel + pacman -S mingw-w64-i686-toolchain make mingw-w64-i686-cmake mingw-w64-i686-boost mingw-w64-i686-openssl mingw-w64-i686-zeromq mingw-w64-i686-libsodium mingw-w64-i686-hidapi mingw-w64-i686-unbound mingw-w64-i686-protobuf git mingw-w64-i686-libusb gettext base-devel ``` 5. Clone repo if installing standalone (skip if building as part of another repo like monero-java or monero-javascript): `git clone --recursive https://github.com/monero-ecosystem/monero-cpp.git` 6. Update submodules: `cd && ./bin/update_submodules.sh` @@ -233,7 +233,7 @@ For example, [monero-java](https://github.com/monero-ecosystem/monero-java) comp For 64 bit: `make release-static-win64` For 32 bit: `make release-static-win32` -10. Build as a shared library in ./build/: `cd ../../ && ./bin/build_libmonero_cpp_dll.sh` +10. Build as a shared library to ./build/: `cd ../../ && ./bin/build_libmonero_cpp.sh` ## Related projects diff --git a/bin/build_libmonero_cpp.sh b/bin/build_libmonero_cpp.sh index fd8603a..8056d10 100755 --- a/bin/build_libmonero_cpp.sh +++ b/bin/build_libmonero_cpp.sh @@ -1,10 +1,23 @@ #!/bin/sh # build monero-project dependencies -HOST_NCORES=$(nproc 2>/dev/null || shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) cd ./external/monero-project/ || exit 1 git submodule update --init --force || exit 1 -make release-static -j$HOST_NCORES || exit 1 +HOST_NCORES=$(nproc 2>/dev/null || shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) +if [[ "$OSTYPE" == "msys" ]]; then + bit=$(getconf LONG_BIT) + if [ "$bit" == "64" ]; then + make release-static-win64 -j$HOST_NCORES || exit 1 + else + make release-static-win32 -j$HOST_NCORES || exit 1 + fi +elif [[ "$OSTYPE" == "cygwin" ]]; then + echo "monero-project supports building on Windows only with MSYS" + exit 1 +else + # OS is not windows + make release-static -j$HOST_NCORES || exit 1 +fi cd ../../ # build libmonero-cpp shared library diff --git a/bin/build_libmonero_cpp_dll.sh b/bin/build_libmonero_cpp_dll.sh deleted file mode 100644 index 2d66571..0000000 --- a/bin/build_libmonero_cpp_dll.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -HOST_NCORES=$(nproc 2>/dev/null || shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 1) - -# build libmonero-cpp shared library -mkdir -p build && -cd build && -cmake .. && -cmake --build . && -make . diff --git a/src/wallet/monero_wallet.h b/src/wallet/monero_wallet.h index 7a36cbb..fad1ad3 100644 --- a/src/wallet/monero_wallet.h +++ b/src/wallet/monero_wallet.h @@ -693,7 +693,7 @@ namespace monero { * Set a subaddress label. * * @param account_idx index of the account to set the label for - * @param subaddressIdx index of the subaddress to set the label for + * @param subaddress_idx index of the subaddress to set the label for * @param label the label to set */ virtual void set_subaddress_label(uint32_t account_idx, uint32_t subaddress_idx, const std::string& label = "") {