rust-bitcoin / rust-bitcoinconsensus

Bitcoin's libbitcoinconsenus.a with Rust binding. Built from Bitcoin sources with cargo.
Apache License 2.0
46 stars 34 forks source link

Unable to build using cross-rs #99

Open KernelPanic0 opened 1 week ago

KernelPanic0 commented 1 week ago

I am trying to cross compile a rust application (from linux, for windows) which interacts with the bitcoin ecosystem. The bitcoinconsensus crate causes an issue as upon building everything builds fine other than this crate.

Warning: build failed, waiting for other jobs to finish...
The following warnings were emitted during compilation:

warning: bitcoinconsensus@0.106.0+26.0: In file included from depend/bitcoin/src/util/strencodings.cpp:7:0:
warning: bitcoinconsensus@0.106.0+26.0: depend/bitcoin/src/util/strencodings.h:15:10: fatal error: charconv: No such file or directory
warning: bitcoinconsensus@0.106.0+26.0:  #include <charconv>
warning: bitcoinconsensus@0.106.0+26.0:           ^~~~~~~~~~
warning: bitcoinconsensus@0.106.0+26.0: compilation terminated.

error: failed to run custom build command for bitcoinconsensus v0.106.0+26.0

Are there any solutions for this?

KernelPanic0 commented 6 days ago

I've tried using a local copy of the bitcoin crate which implements bitcoinconsensus as a feature and edited out the problematic line but still get the following erros:

warning: bitcoinconsensus@0.105.0+25.1: In file included from depend/bitcoin/src/util/strencodings.cpp:7:0:
warning: bitcoinconsensus@0.105.0+25.1: depend/bitcoin/src/util/strencodings.h: In function 'T LocaleIndependentAtoi(std::string_view)':
warning: bitcoinconsensus@0.105.0+25.1: depend/bitcoin/src/util/strencodings.h:132:38: error: 'from_chars' is not a member of 'std'
warning: bitcoinconsensus@0.105.0+25.1:      auto [_, error_condition] = std::from_chars(s.data(), s.data() + s.size(), result);
warning: bitcoinconsensus@0.105.0+25.1:                                       ^~~~~~~~~~
warning: bitcoinconsensus@0.105.0+25.1: depend/bitcoin/src/util/strencodings.h:132:38: note: suggested alternative: '__is_char'
warning: bitcoinconsensus@0.105.0+25.1:      auto [_, error_condition] = std::from_chars(s.data(), s.data() + s.size(), result);
warning: bitcoinconsensus@0.105.0+25.1:                                       ^~~~~~~~~~
warning: bitcoinconsensus@0.105.0+25.1:                                       __is_char
warning: bitcoinconsensus@0.105.0+25.1: depend/bitcoin/src/util/strencodings.h: In function 'std::optional<_Tp> ToIntegral(std::string_view)':
warning: bitcoinconsensus@0.105.0+25.1: depend/bitcoin/src/util/strencodings.h:185:60: error: 'from_chars' is not a member of 'std'
warning: bitcoinconsensus@0.105.0+25.1:      const auto [first_nonmatching, error_condition] = std::from_chars(str.data(), str.data() + str.size(), result);
warning: bitcoinconsensus@0.105.0+25.1:                                                             ^~~~~~~~~~
warning: bitcoinconsensus@0.105.0+25.1: depend/bitcoin/src/util/strencodings.h:185:60: note: suggested alternative: '__is_char'
warning: bitcoinconsensus@0.105.0+25.1:      const auto [first_nonmatching, error_condition] = std::from_chars(str.data(), str.data() + str.size(), result);
warning: bitcoinconsensus@0.105.0+25.1:                                                             ^~~~~~~~~~
warning: bitcoinconsensus@0.105.0+25.1:                                                             __is_char

error: failed to run custom build command for `bitcoinconsensus v0.105.0+25.1 (/var/www/x/bitcoin/bitcoinconsensus)`

It would be amazing If a solution could be provided, or this crate be made cross-rs friendly

apoelstra commented 6 days ago

Sounds like your compiler is not C++17 compatible. We definitely cannot change the upstream library to be C++14.