XRPLF / rippled

Decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++
https://xrpl.org
ISC License
4.48k stars 1.44k forks source link

Compilation error in STAmount.cpp: expected nested-name-specifier before 'enum #5017

Open Xtinc-T opened 1 month ago

Xtinc-T commented 1 month ago

Issue Description

The compilation process of the rippled project encounters an error in the STAmount.cpp file. The error message indicates an issue related to an expected nested-name-specifier before an enumeration (enum), as well as undefined identifiers (upward and downward). This issue prevents the successful completion of the build process.

Steps to Reproduce

So I followed the steps in the reaadme file, I created a C++ environemtn in linux according to the environment.md,

Firstly, I cloned the master branch, I opened up the rippled directory and set up the c++ environment.

I changed directory to .build as specified in the docs, got the cmake tar, did as per the instructions till pip3 install conan

Again I cd rippled/build to create conan profile - conan profile new atharva --detect

conan profile update settings.compiler.libcxx=libstdc++11 atharva

conan profile update settings.compiler.cppstd=20 atharva

conan profile update 'conf.tools.build:compiler_executables={"c": "/usr/bin/gcc", "cpp": "/usr/bin/g++"}' atharva

I made new directory '.build', then followed as per the docs (conan install --install-folder build/generators --build missing --settings build_type=Release ~/Dissertation/attempt_3/rippled/)

cmake -DCMAKE_TOOLCHAIN_FILE=build/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release ~/Dissertation/attempt_3/rippled/

cmake --build . --parallel

This is where I encountered the error, have attached the screenshot. Please take a look as I am a fresher and still learning.

Expected Result

The STAmount.cpp file should compile without errors, allowing the successful completion of the build process for the rippled project.

Actual Result

This is where I encountered the error, have attached the screenshot. Please take a look as I am a fresher and still learning.

Following is the error : [ 17%] Building CXX object CMakeFiles/xrpl_core.dir/proto_gen_grpc/ripple/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.cc.o /home/htewari/Dissertation/attempt_3/rippled/src/ripple/protocol/impl/STAmount.cpp: In lambda function: /home/htewari/Dissertation/attempt_3/rippled/src/ripple/protocol/impl/STAmount.cpp:1588:15: error: expected nested-name-specifier before enum’ 1588 | using enum Number::rounding_mode; | ^~~~ /home/htewari/Dissertation/attempt_3/rippled/src/ripple/protocol/impl/STAmount.cpp:1590:40: error: ‘upward’ was not declared in this scope 1590 | roundUp ^ resultNegative ? upward : downward); | ^~ /home/htewari/Dissertation/attempt_3/rippled/src/ripple/protocol/impl/STAmount.cpp:1590:49: error: ‘downward’ was not declared in this scope 1590 | roundUp ^ resultNegative ? upward : downward); | ^~~~ /home/htewari/Dissertation/attempt_3/rippled/src/ripple/protocol/impl/STAmount.cpp: In instantiation of ‘ripple::STAmount ripple::divRoundImpl(const ripple::STAmount&, const ripple::STAmount&, const ripple::Issue&, bool) [with MightSaveRound = ripple::{anonymous}::DontAffectNumberRoundMode]’: /home/htewari/Dissertation/attempt_3/rippled/src/ripple/protocol/impl/STAmount.cpp:1620:76: required from here /home/htewari/Dissertation/attempt_3/rippled/src/ripple/protocol/impl/STAmount.cpp:1589:30: warning: unused variable ‘savedRound’ [-Wunused-variable] 1589 | MightSaveRound const savedRound( | ^~~~~~ gmake[2]: [CMakeFiles/xrpl_core.dir/build.make:930: CMakeFiles/xrpl_core.dir/src/ripple/protocol/impl/STAmount.cpp.o] Error 1 gmake[2]: Waiting for unfinished jobs.... gmake[1]: [CMakeFiles/Makefile2:178: CMakeFiles/xrpl_core.dir/all] Error 2 gmake[1]: Waiting for unfinished jobs.... [ 17%] Linking C executable noverify_tests [ 17%] Built target noverify_tests [ 17%] Linking C executable tests [ 17%] Built target tests gmake: *** [Makefile:136: all] Error 2

Environment

Debian/ Linux 11 (Bullseye) Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 40 bits physical, 48 bits virtual CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 4

Supporting Files

Screenshot 2024-05-14 151002

legleux commented 1 month ago

Looks like you may have missed the minimum build requirement of GCC-11. You can use the development tools included with Debian 12. (GCC 12.2.0)

If you're needing a build from master, is there any reason you can't use the binary package or Docker image?