#Issues with trying to cross compile rust application from Ubuntu to Windows.

6 messages · Page 1 of 1 (latest)

low bridge
#

I am trying to cross compile a an application that interacts with the bitcoin ecosystem from my ubuntu server to windows using cross-rs.
This application compiles fine up until it reaches a crate called "bitcoinconsensus" (which is a feature of the bitcoin crate).

This is the output I got:

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

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

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

My initial thought was to try editing this line out by copying the crate and just using a local copy, but after this I still get an error:

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

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

I use the following to try to compile:
cross build --target x86_64-pc-windows-gnu

I do not have any issues when compiling on windows. The crate doesnt seem to have a Cross.toml file. Does anyone have any idea on what I can do to get around this or fix it? My last case resort is to just compile my application on an RDP on windows but I really dont want to have to do that.
Thanks guys!

rustic mountain
# low bridge I am trying to cross compile a an application that interacts with the bitcoin ec...

It might be an issue with different versions of C++ being used.
I normally use cargo to cross compile.

rustup target add x86_64-pc-windows-gnu
cargo build --target x86_64-pc-windows-gnu --release

Maybe there is a way to link to a compiled .a library file.
Or it's possible you just need to add -std=c++17 or -std=c++23 to the gcc command.
The only place I see charconv mentioned here is c++26 (https://en.cppreference.com/w/cpp/compiler_support).

low bridge
#

For some reason getting the program to statically link that dll is not possible

rustic mountain
low bridge