Fix and extend cross compilation with static builds
[?]
Mar 22, 2023, 3:38 PM
ZFMPQAFVZP6NC6VZK3YAKIMSS5NYOV47HITL5TQ2YCD3KRCZWREQCDependencies
- [2]
SNMYL7H6Update README - [3]
WK2OO4YYTweak 04 - [4]
5LP7FPFXFix CI - [5]
52F4Q6CJUpdate README - [6]
W2MX3YW4Add CMake and cross example - [7]
EGQ4SEV5Add demo for 04 - [8]
UWWBKZ4RImprove README - [*]
7AUC4NKIInitial commit
Change contents
- replacement in src/CMakeLists.txt at line 5
find_package(CURL REQUIRED)include(FindPkgConfig)pkg_search_module(CURL REQUIRED libcurl) - replacement in src/CMakeLists.txt at line 10
target_link_libraries(wttr-delft PRIVATE CURL::libcurl)target_link_libraries(wttr-delft ${CURL_LIBRARIES})target_include_directories(wttr-delft PUBLIC ${CURL_INCLUDE_DIRS})target_compile_options(wttr-delft PUBLIC ${CURL_CFLAGS_OTHER}) - replacement in README.md at line 26
* [04-cmake-and-cross](04-cmake-and-cross/demo.sh): Building packages that use CMake, and cross-compile them for different architectures.* [04-cmake-and-cross](04-cmake-and-cross/demo.sh): Building packages that use CMake, and cross-compile them for different architectures and static executables. Doing the same with emulation. - edit in 04-cmake-and-cross/wttr-delft.nix at line 4
, pkgconfig - replacement in 04-cmake-and-cross/wttr-delft.nix at line 14
nativeBuildInputs = [ cmake ];nativeBuildInputs = [ cmake pkgconfig ]; - replacement in 04-cmake-and-cross/flake.nix at line 27
packages.default = pkgs.wttr-delft;# But the package set also has a pkgsCross set, and we can select our package from one of its contentspackages.cross-riscv64 = pkgs.pkgsCross.riscv64.wttr-delft;packages = {default = pkgs.wttr-delft;# But the package set also has a pkgsCross set, and we can select our package from one of its contentscross-riscv64 = pkgs.pkgsCross.riscv64.wttr-delft;static = pkgs.pkgsCross.musl64.pkgsStatic.wttr-delft;cross-aarch64-static = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic.wttr-delft;}; - edit in 04-cmake-and-cross/demo.sh at line 24
# x nix build "${dir}" -L --rebuildh Checking out the closure - edit in 04-cmake-and-cross/demo.sh at line 25
n The \'closure\' is the full set of all the \(runtime\) dependencies:x nix path-info -sSrh ./result - replacement in 04-cmake-and-cross/demo.sh at line 34
x nix build "${dir}#cross-riscv64"x nix build "${dir}#cross-riscv64" -L - edit in 04-cmake-and-cross/demo.sh at line 38
h Static executables, We can also cross compile a static build:x nix build "${dir}#static" -L, And this is indeed a static binary:x "${file_cmd}" ./result/bin/wttr-delftx ls -lh ./result/bin/wttr-delfth Everything together, Static cross compiled for aarch64-linux - you can copy this executable and run it on a Raspberry Pi!x nix build "${dir}#cross-aarch64-static" -Lx "${file_cmd}" ./result/bin/wttr-delftx ls -lh ./result/bin/wttr-delft - replacement in 04-cmake-and-cross/demo.sh at line 61
p[4.2139], And we can actually run it as well!x ./result/bin/wttr-delft