monero-cpp icon indicating copy to clipboard operation
monero-cpp copied to clipboard

Missing libwallet-crypto.a

Open aquilacf opened this issue 2 years ago • 12 comments

Hi there, I am struggling to build the library on my Apple M1 (I managed to build on Linux, Apple Intel, and using buildx of docker). I had to make some tweaks to build monero statically (tip from https://github.com/monero-project/monero/issues/8332) but, I can't find why the library libwallet-crypto.a wasn't built by monero.

Tried to upload the monero compilation logs somewhere but it was too big. Let me know if you need an specific part of it.

monero-cpp compilation:

-- The C compiler identification is Clang 14.0.6
-- The CXX compiler identification is Clang 14.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/opt/llvm/bin/clang - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- EXTERNAL_LIBS_DIR:/Users/aquila.freitas/Projects/Personal/Monero/monero-cpp/external-libs
-- EXTRA_LIBRARIES:/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/IOKit.framework/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AppKit.framework
-- Found Protobuf: /opt/homebrew/lib/libprotobuf.dylib (found version "3.21.2")
-- Protobuf lib: /opt/homebrew/lib/libprotobuf.dylib, inc: /opt/homebrew/include, protoc: /opt/homebrew/bin/protoc
-- Using Boost include dir at /opt/homebrew/include
-- Using OpenSSL found at /opt/homebrew/opt/openssl@3
-- Found OpenSSL: /opt/homebrew/opt/openssl@3/lib/libcrypto.dylib (found version "3.0.5")
-- Using OpenSSL include dir at /opt/homebrew/opt/openssl@3/include
-- Using libsodium library at /opt/homebrew/lib/libsodium.dylib
-- Found HIDAPI: /opt/homebrew/lib/libhidapi.dylib
-- Using HIDAPI include dir at /opt/homebrew/include/hidapi
-- Using monero-project build:/Users/aquila.freitas/Projects/Personal/Monero/monero-cpp/external/monero-project/build/release
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/aquila.freitas/Projects/Personal/Monero/monero-cpp/build
[ 12%] Building CXX object CMakeFiles/monero-cpp.dir/src/utils/gen_utils.cpp.o
[ 25%] Building CXX object CMakeFiles/monero-cpp.dir/src/utils/monero_utils.cpp.o
[ 37%] Building CXX object CMakeFiles/monero-cpp.dir/src/daemon/monero_daemon_model.cpp.o
[ 50%] Building CXX object CMakeFiles/monero-cpp.dir/src/daemon/monero_daemon.cpp.o
[ 62%] Building CXX object CMakeFiles/monero-cpp.dir/src/wallet/monero_wallet_model.cpp.o
[ 75%] Building CXX object CMakeFiles/monero-cpp.dir/src/wallet/monero_wallet_keys.cpp.o
[ 87%] Building CXX object CMakeFiles/monero-cpp.dir/src/wallet/monero_wallet_full.cpp.o
In file included from /Users/aquila.freitas/Projects/Personal/Monero/monero-cpp/src/wallet/monero_wallet_full.cpp:60:
/Users/aquila.freitas/Projects/Personal/Monero/monero-cpp/external/monero-project/src/wallet/wallet_rpc_server_commands_defs.h:51:9: warning: 'WALLET_RPC_VERSION_MINOR' macro redefined [-Wmacro-redefined]
#define WALLET_RPC_VERSION_MINOR 24
        ^
/Users/aquila.freitas/Projects/Personal/Monero/monero-cpp/external/monero-project/src/wallet/wallet_rpc_server_commands_defs.h:50:9: note: previous definition is here
#define WALLET_RPC_VERSION_MINOR 22
        ^
1 warning generated.
gmake[2]: *** No rule to make target '../external/monero-project/build/release/src/crypto/wallet/libwallet-crypto.a', needed by 'libmonero-cpp.dylib'.  Stop.
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/monero-cpp.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

aquilacf avatar Jul 18 '22 10:07 aquilacf

libwallet-crypto.a is built as part of monero-project, which is built separately from this project, so that's the first step to solve.

monero-project is included as an external project in monero-cpp.

You should be able to manually cd $MONERO_CPP/external/monero-project && make release-static -j8 && make release-static -j8 and confirm that the build completes. If there are any build errors, then the *.a files won't be created, so we just need to work through the build errors until that finishes.

After that, the file should be built at ../external/monero-project/build/release/src/crypto/wallet/libwallet-crypto.a, and this library can be built.

woodser avatar Jul 21 '22 16:07 woodser

Also, libwallet-crypto.a is only built on *nix systems, not Windows.

woodser avatar Jul 24 '22 15:07 woodser

You should be able to manually cd $MONERO_CPP/external/monero-project && make release-static -j8 && make release-static -j8 and confirm that the build completes.

I can confirm the build completes successfully. Only libwallet-crypto.a missing.

Also, libwallet-crypto.a is only built on *nix systems, not Windows.

I am on a Mac. I did test on an Intel based Mac and the lib exists there. Could libwallet-crypto.a also not be built on M1? I do get the CMake files: image

aquilacf avatar Jul 26 '22 13:07 aquilacf

Could libwallet-crypto.a also not be built on M1?

I couldn't tell you. It's good to know it worked on Intel as a baseline. Sounds like something needs updated for the new hardware.

woodser avatar Jul 26 '22 21:07 woodser

A new version of this library is released, v0.7.2, which updates the dependencies for monero-project v0.18.0.0 (for example, libwallet_merged.a had been completely removed). Please let me know if you continue to have problems with this new version. Thanks.

woodser avatar Aug 07 '22 13:08 woodser

I am still missing the libwallet-crypto.a on v0.18.0.0. I will ask someone on monero-project about this. Quick question, as libwallet_merged.a have been removed, do we still need to double make release-static?

aquilacf avatar Aug 08 '22 11:08 aquilacf

I found out that libwallet-crypto.a is only built on x86_64 systems to provide asm for some wallet functions.

https://github.com/monero-ecosystem/monero-cpp/pull/18 imports that library only if it exists, and should hopefully resolve this issue.

No need to make release-static twice anymore. Good catch, I'll update the docs. :)

woodser avatar Aug 08 '22 21:08 woodser

Just tested fix_libwallet_crypto and that did go through, thanks! I just got stuck with some epee dependencies now: build.txt Have you seen these errors before?

aquilacf avatar Aug 09 '22 08:08 aquilacf

Looks like it can't find SSL libs.

Running ./bin/build_libmonero_cpp.sh ought to locate your environment's SSL package and print output like Using OpenSSL at /usr/local/opt/openssl@3. Does it? I don't see anything about it in your build log, but it looks like you used a modified command.

Somehow we need to modify SSL import in CMakeLists.txt to import your system's SSL.

woodser avatar Aug 09 '22 14:08 woodser

Good point, I did make some modifications and forgot to revert. Just to let you know, it's possible to compile monero-cpp on M1 by replacing -march=x86-64 with -mcpu=native. Monero Project needs this change to build statically on M1 though.

Feel free close the issue one #18 goes through. Appreciate your help and congrats for the good work.

aquilacf avatar Aug 10 '22 19:08 aquilacf

Looks like it can't find SSL libs.

Running ./bin/build_libmonero_cpp.sh ought to locate your environment's SSL package and print output like Using OpenSSL at /usr/local/opt/openssl@3. Does it? I don't see anything about it in your build log, but it looks like you used a modified command.

Somehow we need to modify SSL import in CMakeLists.txt to import your system's SSL.

Install brew install [email protected] uninstall openssl@3

crossle avatar Oct 05 '22 12:10 crossle

I also had success by modifying EXECUTE_PROCESS(COMMAND brew --prefix openssl to EXECUTE_PROCESS(COMMAND brew --prefix [email protected].

woodser avatar Oct 05 '22 13:10 woodser

Fixed with https://github.com/monero-ecosystem/monero-cpp/commit/7d6e456cc4d266df8348db5b9d4b76924eebac4e.

woodser avatar Jan 04 '23 18:01 woodser