From 4a79d8f11357a60b2f56432bd3586566d7231075 Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 4 Jan 2020 13:50:15 -0500 Subject: [PATCH 1/4] prepend ./ to path --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7295202..0abd772 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,7 @@ set_target_properties(boost_thread PROPERTIES IMPORTED_LOCATION # OpenSSL ############ -include_directories(external/openssl-sdk/include) +include_directories(./external/openssl-sdk/include) add_library(crypto STATIC IMPORTED) set_target_properties(crypto PROPERTIES IMPORTED_LOCATION From 7a658ec65db65554173d0675a01f1d9f05f8b3a5 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 5 Jan 2020 09:36:18 -0500 Subject: [PATCH 2/4] build script uses libs built in monero-core submodule --- CMakeLists.txt | 54 ++++++++++++++++++++------------------ bin/build-libmonero-cpp.sh | 6 +++++ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0abd772..7493b72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ project(MoneroCppLibrary) # monero-project ################### -set(MONERO_CORE "external/monero-core") +set(MONERO_CORE "${CMAKE_SOURCE_DIR}/external/monero-core") set(MONERO_CORE_SRC "${MONERO_CORE}/src") # header includes @@ -73,11 +73,12 @@ set_target_properties(hidapi PROPERTIES IMPORTED_LOCATION #SET(BOOST_SRC ${BOOST}/boost) #SET(BOOST_LIB ${BOOST}/stage/lib) -SET(BOOST external/boost-sdk) +set(Boost_USE_MULTITHREADED ON) +SET(BOOST ${CMAKE_SOURCE_DIR}/external/boost-sdk) include_directories(${BOOST}) link_directories(${EXTERNAL_LIBS_DIR}/boost) -find_package(Boost 1.69 REQUIRED COMPONENTS chrono date_time filesystem program_options regex serialization wserialization system thread) +find_package(Boost 1.72 REQUIRED COMPONENTS chrono date_time filesystem program_options regex serialization wserialization system thread) add_library(boost_chrono STATIC IMPORTED) set_target_properties(boost_chrono PROPERTIES IMPORTED_LOCATION @@ -113,7 +114,7 @@ set_target_properties(boost_system PROPERTIES IMPORTED_LOCATION add_library(boost_thread STATIC IMPORTED) set_target_properties(boost_thread PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/boost/libboost_thread-mt.a) + ${EXTERNAL_LIBS_DIR}/boost/libboost_thread.a) ############ # OpenSSL @@ -143,89 +144,92 @@ set_target_properties(sodium PROPERTIES IMPORTED_LOCATION # Monero ############# +set(MONERO_CORE_BUILD "${MONERO_CORE}/build/release") +message(STATUS MONERO_CORE_BUILD : ${MONERO_CORE_BUILD}) + add_library(wallet_merged STATIC IMPORTED) set_target_properties(wallet_merged PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libwallet_merged.a) + ${MONERO_CORE_BUILD}/lib/libwallet_merged.a) add_library(wallet STATIC IMPORTED) set_target_properties(wallet PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libwallet.a) + ${MONERO_CORE_BUILD}/lib/libwallet.a) add_library(lmdb STATIC IMPORTED) set_target_properties(lmdb PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/liblmdb.a) + ${MONERO_CORE_BUILD}/external/db_drivers/liblmdb/liblmdb.a) add_library(epee STATIC IMPORTED) set_target_properties(epee PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libepee.a) + ${MONERO_CORE_BUILD}/contrib/epee/src/libepee.a) add_library(unbound STATIC IMPORTED) set_target_properties(unbound PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libunbound.a) + ${MONERO_CORE_BUILD}/external/unbound/libunbound.a) add_library(easylogging STATIC IMPORTED) set_target_properties(easylogging PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libeasylogging.a) + ${MONERO_CORE_BUILD}/external/easylogging++/libeasylogging.a) add_library(cryptonote_core STATIC IMPORTED) set_target_properties(cryptonote_core PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libcryptonote_core.a) + ${MONERO_CORE_BUILD}/src/cryptonote_core/libcryptonote_core.a) add_library(cryptonote_basic STATIC IMPORTED) set_target_properties(cryptonote_basic PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libcryptonote_basic.a) + ${MONERO_CORE_BUILD}/src/cryptonote_basic/libcryptonote_basic.a) add_library(mnemonics STATIC IMPORTED) set_target_properties(mnemonics PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libmnemonics.a) + ${MONERO_CORE_BUILD}/src/mnemonics/libmnemonics.a) add_library(common STATIC IMPORTED) set_target_properties(common PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libcommon.a) + ${MONERO_CORE_BUILD}/src/common/libcommon.a) add_library(cncrypto STATIC IMPORTED) set_target_properties(cncrypto PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libcncrypto.a) + ${MONERO_CORE_BUILD}/src/crypto/libcncrypto.a) add_library(ringct STATIC IMPORTED) set_target_properties(ringct PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libringct.a) + ${MONERO_CORE_BUILD}/src/ringct/libringct.a) add_library(ringct_basic STATIC IMPORTED) set_target_properties(ringct_basic PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libringct_basic.a) + ${MONERO_CORE_BUILD}/src/ringct/libringct_basic.a) add_library(blockchain_db STATIC IMPORTED) set_target_properties(blockchain_db PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libblockchain_db.a) + ${MONERO_CORE_BUILD}/src/blockchain_db/libblockchain_db.a) add_library(blocks STATIC IMPORTED) set_target_properties(blocks PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libblocks.a) + ${MONERO_CORE_BUILD}/src/blocks/libblocks.a) add_library(checkpoints STATIC IMPORTED) set_target_properties(checkpoints PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libcheckpoints.a) + ${MONERO_CORE_BUILD}/src/checkpoints/libcheckpoints.a) add_library(device STATIC IMPORTED) set_target_properties(device PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libdevice.a) + ${MONERO_CORE_BUILD}/src/device/libdevice.a) add_library(device_trezor STATIC IMPORTED) set_target_properties(device_trezor PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libdevice_trezor.a) + ${MONERO_CORE_BUILD}/src/device_trezor/libdevice_trezor.a) add_library(multisig STATIC IMPORTED) set_target_properties(multisig PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libmultisig.a) + ${MONERO_CORE_BUILD}/src/multisig/libmultisig.a) add_library(version STATIC IMPORTED) set_target_properties(version PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/libversion.a) + ${MONERO_CORE_BUILD}/src/libversion.a) add_library(randomx STATIC IMPORTED) set_target_properties(randomx PROPERTIES IMPORTED_LOCATION - ${EXTERNAL_LIBS_DIR}/monero-core/librandomx.a) + ${MONERO_CORE_BUILD}/external/randomx/librandomx.a) ######################## # Build c++ library diff --git a/bin/build-libmonero-cpp.sh b/bin/build-libmonero-cpp.sh index 0c181ca..1f1a546 100755 --- a/bin/build-libmonero-cpp.sh +++ b/bin/build-libmonero-cpp.sh @@ -1,5 +1,11 @@ #!/bin/sh +# Make libmonero-cpp.dylib +cd ./external/monero-core/ && +make release-static -j8 && + +# Make libmonero-cpp.dylib +cd ../../ && mkdir -p build && cd build && cmake .. && From 73c2150b95132d7ab3b23ff90788b11d9861d46e Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 5 Jan 2020 09:51:16 -0500 Subject: [PATCH 3/4] readme cleanup --- README.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index bc871eb..c2f7ab3 100644 --- a/README.md +++ b/README.md @@ -143,35 +143,33 @@ wallet_restored->relay_tx(*created_tx); // submit the transaction to the Monero The following dependencies must be set up before running this project. 1. Set up Boost - 1. Download and extract the boost 1.69.0 source code zip from https://www.boost.org/users/download/ to ./external/boost-sdk/. + 1. Download and extract the boost 1.72.0 source code zip from https://www.boost.org/users/download/ to ./external/boost-sdk/. 2. `cd ./external/boost-sdk/` - 3. `./bootstraph.sh` + 3. `./bootstrap.sh` 4. `./b2` 5. Copy .a files from ./external/boost-sdk/bin.v2/libs/\*/link-static/\* to ./external-libs/boost according to CMakeLists.txt. 2. Set up OpenSSL 1. Download and extract the latest OpenSSL source code zip from https://github.com/openssl/openssl to ./external/openssl-sdk/. 2. Build for your system.
Mac: installed through boost at /usr/local/opt/openssl/lib - 3. Copy libcrypto.a and libssl.a ./external-libs/openssl. -3. Set up Monero Core - 1. Initialize submodules: `git submodule update --init --recursive` - 2. cd ./submodules/monero-core - 3. Modify CMakeLists.txt: `option(BUILD_GUI_DEPS "Build GUI dependencies." ON)`. - 4. Build twice to create libwallet_merged.a in addition to other .a libraries: `make release-static -j8`. - 5. Copy .a files from ./submodules/monero-core/build/release/* to ./external-libs/monero-core according to CMakeLists.txt. -4. Set up hidapi + 3. Copy libcrypto.a and libssl.a ./external-libs/openssl +3. Set up hidapi 1. Download the latest hidapi source code from https://github.com/signal11/hidapi. 2. Build hidapi for your system.
Mac requires autoreconf: `brew install automake` 3. Copy libhidapi.a to ./external-libs/hidapi. -5. Set up libsodium +4. Set up libsodium 1. Build libsodium for your system. 2. Copy libsodium.a to ./external-libs/libsodium.
Mac: installed through homebrew at /usr/local/Cellar/libsodium/1.0.17/lib/libsodium.a +5. Set up Monero Core + 1. Initialize submodules: `git submodule update --init --recursive` + 2. cd ./submodules/monero-core + 3. Modify CMakeLists.txt: `option(BUILD_GUI_DEPS "Build GUI dependencies." ON)`. + 4. Build twice to create libwallet_merged.a in addition to other .a libraries: `make release-static -j8`. +6. Build this project as a dynamic library at `./build/libmonero-cpp.dylib`: `./bin/build-libmonero-cpp.sh`. -After the dependencies are set up, this project may be compiled as part of another application, as a dynamic library, or as a shared library. For example, the associated [Java library](https://github.com/monero-ecosystem/monero-java-rpc) depends on a dynamic library built from this project to support a wallet using Java JNI. - -To build this project as a dynamic library at `./build/libmonero-cpp.dylib`, execute: `./bin/build-libmonero-cpp.sh`. +This project may be compiled as part of another application, as a dynamic library, or as a shared library. For example, the associated [Java library](https://github.com/monero-ecosystem/monero-java-rpc) depends on a dynamic library built from this project to support a wallet using Java JNI. These build steps aspire to be automated further and [any help is greatly appreciated](https://github.com/woodser/monero-cpp-library/issues/1). From 7d29190cef9c803c3c9243d50fa1ab5c3a326d58 Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 5 Jan 2020 11:12:40 -0500 Subject: [PATCH 4/4] update scratchpad --- test/scratchpad.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/scratchpad.cpp b/test/scratchpad.cpp index 41a5cf6..28e3a0e 100644 --- a/test/scratchpad.cpp +++ b/test/scratchpad.cpp @@ -1,7 +1,7 @@ #include #include #include "wallet2.h" -#include "wallet/monero_wallet.h" +#include "wallet/monero_wallet_core.h" using namespace std; @@ -29,7 +29,7 @@ int main(int argc, const char* argv[]) { int network_type = 2; // load wallet - monero_wallet* wallet = monero_wallet::open_wallet("../../test_wallets/test_wallet_1", "supersecretpassword123", monero_network_type::STAGENET); + monero_wallet* wallet = monero_wallet_core::open_wallet("../../test_wallets/test_wallet_1", "supersecretpassword123", monero_network_type::STAGENET); wallet->set_daemon_connection("http://localhost:38081", "", ""); // fetch txs