diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml
index 4259b1a9..1e0015c4 100644
--- a/.github/workflows/build-macos.yml
+++ b/.github/workflows/build-macos.yml
@@ -60,6 +60,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: monero-${{ matrix.os }}
- path: |
- dist/*.whl
- external/monero-cpp/build/libmonero-cpp.dylib
+ path: dist/*.whl
diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml
index 39c8fe76..7b54e85f 100644
--- a/.github/workflows/build-windows.yml
+++ b/.github/workflows/build-windows.yml
@@ -103,7 +103,6 @@ jobs:
-DPython3_FIND_REGISTRY=NEVER
cmake --build .
mkdir -p ../dist
- cp ../external/monero-cpp/build/libmonero-cpp.dll ../dist
cp *.pyd ../dist/monero.pyd
cd ../dist
ntldd -R *.pyd | grep mingw64 | awk '{print $3}' | while read -r line; do
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index ce79b3c2..97db0857 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -70,7 +70,6 @@ jobs:
cmake .. -DENABLE_COVERAGE=ON
cmake --build .
make -j3
- sudo cp libmonero-cpp.so /usr/lib/
cd ../../../
- name: Install monero-python
@@ -246,7 +245,6 @@ jobs:
-DPython3_FIND_REGISTRY=NEVER
cmake --build .
mkdir -p ../dist
- cp ../external/monero-cpp/build/libmonero-cpp.dll ../dist
cp *.pyd ../dist/monero.pyd
cd ../dist
ntldd -R *.pyd | grep mingw64 | awk '{print $3}' | while read -r line; do
@@ -301,7 +299,6 @@ jobs:
cmake ..
cmake --build .
make -j3
- cp libmonero-cpp.dylib /opt/homebrew/lib/
cd ../../../
- name: Install monero-python
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6912c2d0..8a85dc29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,18 +20,130 @@ if(ENABLE_COVERAGE)
endif()
###################
-# monero-cpp
+# Monero C++
###################
set(MONERO_CPP "${CMAKE_SOURCE_DIR}/external/monero-cpp" CACHE STRING "Monero c++ source directory")
set(MONERO_CPP_SRC "${MONERO_CPP}/src")
+set(MONERO_CPP_BUILD "${MONERO_CPP}/build")
+
+add_library(monero-cpp STATIC IMPORTED)
+set_target_properties(monero-cpp PROPERTIES IMPORTED_LOCATION
+ ${MONERO_CPP_BUILD}/libmonero-cpp.a)
###################
-# monero-project
+# Monero
###################
set(MONERO_PROJECT "${MONERO_CPP}/external/monero-project" CACHE STRING "Monero project source directory")
set(MONERO_PROJECT_SRC "${MONERO_PROJECT}/src")
+set(MONERO_PROJECT_BUILD "${MONERO_PROJECT}/build/release" CACHE STRING "Monero project build directory")
+
+list(APPEND CMAKE_MODULE_PATH "${MONERO_PROJECT}/cmake")
+
+add_library(wallet STATIC IMPORTED)
+set_target_properties(wallet PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/lib/libwallet.a)
+
+# libwallet-crypto.a provides x86_64 asm for some wallet functions
+if (EXISTS ${MONERO_PROJECT_BUILD}/src/crypto/wallet/libwallet-crypto.a)
+ add_library(wallet_crypto_lib STATIC IMPORTED)
+ set_target_properties(wallet_crypto_lib PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/crypto/wallet/libwallet-crypto.a)
+ set(wallet_crypto wallet_crypto_lib)
+endif()
+
+add_library(lmdb STATIC IMPORTED)
+set_target_properties(lmdb PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/external/db_drivers/liblmdb/liblmdb.a)
+
+add_library(epee STATIC IMPORTED)
+set_target_properties(epee PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/contrib/epee/src/libepee.a)
+
+add_library(rpc_base STATIC IMPORTED)
+set_target_properties(rpc_base PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/rpc/librpc_base.a)
+
+add_library(net STATIC IMPORTED)
+set_target_properties(net PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/net/libnet.a)
+
+add_library(hardforks STATIC IMPORTED)
+set_target_properties(hardforks PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/hardforks/libhardforks.a)
+
+add_library(easylogging STATIC IMPORTED)
+set_target_properties(easylogging PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/external/easylogging++/libeasylogging.a)
+
+add_library(cryptonote_core STATIC IMPORTED)
+set_target_properties(cryptonote_core PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/cryptonote_core/libcryptonote_core.a)
+
+add_library(cryptonote_protocol STATIC IMPORTED)
+set_target_properties(cryptonote_protocol PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/cryptonote_protocol/libcryptonote_protocol.a)
+
+add_library(cryptonote_basic STATIC IMPORTED)
+set_target_properties(cryptonote_basic PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/cryptonote_basic/libcryptonote_basic.a)
+
+add_library(cryptonote_format_utils_basic STATIC IMPORTED)
+set_target_properties(cryptonote_format_utils_basic PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/cryptonote_basic/libcryptonote_format_utils_basic.a)
+
+add_library(mnemonics STATIC IMPORTED)
+set_target_properties(mnemonics PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/mnemonics/libmnemonics.a)
+
+add_library(common STATIC IMPORTED)
+set_target_properties(common PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/common/libcommon.a)
+
+add_library(cncrypto STATIC IMPORTED)
+set_target_properties(cncrypto PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/crypto/libcncrypto.a)
+
+add_library(ringct STATIC IMPORTED)
+set_target_properties(ringct PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/ringct/libringct.a)
+
+add_library(ringct_basic STATIC IMPORTED)
+set_target_properties(ringct_basic PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/ringct/libringct_basic.a)
+
+add_library(blockchain_db STATIC IMPORTED)
+set_target_properties(blockchain_db PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/blockchain_db/libblockchain_db.a)
+
+add_library(blocks STATIC IMPORTED)
+set_target_properties(blocks PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/blocks/libblocks.a)
+
+add_library(checkpoints STATIC IMPORTED)
+set_target_properties(checkpoints PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/checkpoints/libcheckpoints.a)
+
+add_library(device STATIC IMPORTED)
+set_target_properties(device PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/device/libdevice.a)
+
+add_library(device_trezor STATIC IMPORTED)
+set_target_properties(device_trezor PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/device_trezor/libdevice_trezor.a)
+
+add_library(multisig STATIC IMPORTED)
+set_target_properties(multisig PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/multisig/libmultisig.a)
+
+add_library(version STATIC IMPORTED)
+set_target_properties(version PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/src/libversion.a)
+
+add_library(randomx STATIC IMPORTED)
+set_target_properties(randomx PROPERTIES IMPORTED_LOCATION
+ ${MONERO_PROJECT_BUILD}/external/randomx/librandomx.a)
############
# Threads
@@ -58,7 +170,7 @@ find_package(pybind11 REQUIRED)
set(Boost_NO_BOOST_CMAKE 1)
set(Boost_USE_MULTITHREADED ON)
-set(BOOST_COMPONENTS thread serialization filesystem)
+set(BOOST_COMPONENTS thread serialization filesystem program_options)
# Find Boost headers
set(BOOST_MIN_VER 1.62)
@@ -84,6 +196,59 @@ if (WIN32)
list(APPEND OPENSSL_LIBRARIES ws2_32 crypt32 bcrypt)
endif()
+############
+# Unbound
+############
+
+find_package(Unbound REQUIRED)
+message(STATUS "Using libunbound library at ${UNBOUND_LIBRARIES}")
+
+if (APPLE)
+ find_library(EXPAT_LIBRARY expat HINTS /opt/homebrew/opt/expat/lib /usr/local/opt/expat/lib)
+ if (EXPAT_LIBRARY)
+ list(APPEND UNBOUND_LIBRARIES ${EXPAT_LIBRARY})
+ endif()
+ find_library(EVENT_LIBRARY NAMES event event_core HINTS /opt/homebrew/opt/libevent/lib /usr/local/opt/libevent/lib)
+ if (EVENT_LIBRARY)
+ list(APPEND UNBOUND_LIBRARIES ${EVENT_LIBRARY})
+ endif()
+ find_library(NGHTTP2_LIBRARY nghttp2 HINTS /opt/homebrew/opt/libnghttp2/lib /usr/local/opt/libnghttp2/lib)
+ if (NGHTTP2_LIBRARY)
+ list(APPEND UNBOUND_LIBRARIES ${NGHTTP2_LIBRARY})
+ endif()
+endif()
+
+############
+# LibUSB
+############
+
+find_library(usb_LIBRARY NAMES usb-1.0 libusb usb)
+set(LibUSB_LIBRARIES ${usb_LIBRARY})
+
+############
+# HIDAPI
+############
+
+find_package(HIDAPI REQUIRED)
+message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}")
+
+############
+# libsodium
+############
+
+find_library(SODIUM_LIBRARY sodium REQUIRED)
+message(STATUS "Using libsodium library at ${SODIUM_LIBRARY}")
+
+############
+# Protobuf
+############
+
+if (NOT APPLE)
+ include(FindProtobuf)
+ find_package(Protobuf)
+ message(STATUS "Protobuf lib: ${Protobuf_LIBRARY}, inc: ${Protobuf_INCLUDE_DIR}, protoc: ${Protobuf_PROTOC_EXECUTABLE}")
+endif()
+
########################
# Build python library
########################
@@ -94,10 +259,6 @@ set(LIBRARY_SRC_FILES
src/cpp/py_monero.cpp
)
-link_directories(
- ${MONERO_CPP}/build
-)
-
pybind11_add_module(monero ${LIBRARY_SRC_FILES})
if (WIN32)
@@ -115,14 +276,49 @@ target_include_directories(monero PRIVATE
${pybind11_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
+ ${HIDAPI_INCLUDE_DIR}
+ ${Protobuf_INCLUDE_DIR}
+ ${UNBOUND_INCLUDE_DIR}
)
-target_link_libraries(monero PRIVATE
+set(MONERO_PYTHON_LINK_LIBS
monero-cpp
+ wallet
+ rpc_base
+ net
+ lmdb
+ easylogging
+ cryptonote_core
+ cryptonote_protocol
+ cryptonote_basic
+ cryptonote_format_utils_basic
+ mnemonics
+ ringct
+ ringct_basic
+ common
+ blockchain_db
+ blocks
+ checkpoints
+ device
+ device_trezor
+ multisig
+ version
+ cncrypto
+ randomx
+ epee
+ hardforks
+ ${wallet_crypto}
Threads::Threads
${Boost_LIBRARIES}
${OPENSSL_LIBRARIES}
+ ${Protobuf_LIBRARY}
+ ${LibUSB_LIBRARIES}
+ ${SODIUM_LIBRARY}
+ ${HIDAPI_LIBRARIES}
+ ${UNBOUND_LIBRARIES}
)
+target_link_libraries(monero PRIVATE ${MONERO_PYTHON_LINK_LIBS})
+
install(TARGETS monero DESTINATION .)
diff --git a/README.md b/README.md
index 01d73b4e..c5a23a18 100644
--- a/README.md
+++ b/README.md
@@ -108,11 +108,7 @@ wallet_full.close(True)
git clone --recurse-submodules https://github.com/everoddandeven/monero-python.git
```
3. Build the monero-cpp submodule (located at `./external/monero-cpp`) as a native library by following [instructions](https://github.com/woodser/monero-cpp#using-monero-cpp-in-your-project) for your system.
-4. Copy shared library `./external/monero-cpp/build/libmonero-cpp.so` to `/usr/lib`:
- ```
- sudo cp ./external/monero-cpp/build/libmonero-cpp.so /usr/lib/
- ```
-5. Build monero-python to `./build/`:
+4. Build monero-python to `./build/`:
```bash
cd monero-python
mkdir -p build
@@ -120,11 +116,11 @@ wallet_full.close(True)
cmake ..
make
```
-6. Or build and install monero-python with pip:
+5. Or build and install monero-python with pip:
```bash
pip3 install . --break-system-packages
```
-7. Or run build script: `./bin/build_libmonero_python.sh`
+6. Or run build script: `./bin/build_libmonero_python.sh`
### Linux Docker Build
diff --git a/docker/build.sh b/docker/build.sh
index 0915fc68..dbfc1aed 100755
--- a/docker/build.sh
+++ b/docker/build.sh
@@ -60,7 +60,6 @@ cp -R src/python build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/monero
rm -rf build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/pybind11*
rm -rf build/${PACKAGE_NAME}/usr/lib/python3/dist-packages/bin
cp -R "debian/${DISTRO_CODENAME}" "build/${PACKAGE_NAME}/DEBIAN"
-cp external/monero-cpp/build/libmonero-cpp.so build/${PACKAGE_NAME}/usr/lib/
CONTROL_FILE="build/${PACKAGE_NAME}/DEBIAN/control"
if [ -f "$CONTROL_FILE" ]; then