SatDump
SatDump copied to clipboard
Building on Linux and running UI fail
Hello! I've been trying to build SatDump on two Linux machines, and ran into lots of trouble in the process. I'm using the following tiny Nix flake to have a reproducible build environment:
{
description = ( "SatDump - A generic satellite data processing software" );
inputs = {
nixpkgs = { url = "github:NixOS/nixpkgs/release-23.11"; };
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
dependencies = [
pkgs.git pkgs.gnumake pkgs.cmake pkgs.libgcc pkgs.pkgconf
pkgs.fftwFloat pkgs.libpng pkgs.libtiff pkgs.jemalloc
pkgs.volk pkgs.nng pkgs.rtl-sdr pkgs.hackrf pkgs.airspy pkgs.airspyhf
pkgs.glfw pkgs.gnome.zenity
pkgs.zstd
];
in
{
devShells.${system}.default = pkgs.mkShell {
buildInputs = dependencies;
};
};
}
As you can see, I just adapted the dependencies from the README.
Interestingly enough, mbedtls
is listed as a dependency only for MacOS, which brings me to the first issue.
Part 1 - Building fails
I generate the Makefiles with cmake -DCMAKE_BUILD_TYPE=Release ..
Building then fails, among other things, with linker issues:
[ 97%] Linking CXX executable ../satdump
/nix/store/bs8irpchp9yrp2azs3arm0b88mrsip6d-binutils-2.40/bin/ld: ../libsatdump_core.so: undefined reference to `mbedtls_ssl_init'
/nix/store/bs8irpchp9yrp2azs3arm0b88mrsip6d-binutils-2.40/bin/ld: ../libsatdump_core.so: undefined reference to `mbedtls_ssl_set_hostname'
/nix/store/bs8irpchp9yrp2azs3arm0b88mrsip6d-binutils-2.40/bin/ld: ../libsatdump_core.so: undefined reference to `mbedtls_ssl_conf_dbg'
[...]
This is resolved by adding pkgs.mbedtls
to the build dependencies, and changing src-core/CMakeLists.txt
to link mbedtls
in the appropriate location
diff --git a/src-core/CMakeLists.txt b/src-core/CMakeLists.txt
index 8597913c..b4423a0f 100644
--- a/src-core/CMakeLists.txt
+++ b/src-core/CMakeLists.txt
@@ -149,6 +149,8 @@ else()
find_library(NNG_LIBRARY nng REQUIRED)
target_link_libraries(satdump_core PUBLIC ${NNG_LIBRARY})
+ target_link_libraries(satdump_core PUBLIC mbedtls)
+
if(BUILD_ZIQ)
# zstd
find_library(ZSTD_LIBRARY zstd REQUIRED)
The next error is
satdump/plugins/sdr_sources/sdrpp_server_support/sdrpp_server/smgui.cpp: In function 'void SmGui::LeftLabel(const char*)':
satdump/plugins/sdr_sources/sdrpp_server_support/sdrpp_server/smgui.cpp:564:39: error: format not a string literal and no format arguments [-Werror=format-security]
564 | if (!serverMode) { ImGui::Text(text); ImGui::SameLine(); return; } // LeftLabel?
| ~~~~~~~~~~~^~~~~~
The file src-core-imgui/imgui_demo.cpp
already contains a bandaid fix which I can just copy.
#pragma GCC diagnostic ignored "-Wformat-security" // warning: format string is not a string literal
Now finally, the build completes successfully.
I have tested this on the master branch at b1087fc240c96542c9911b5347fb1860a66829af
, the nightly at 57cb01f253d0bb70327d9a2c26b68ad5e2f66d80
and the 1.1.4 tag.
Part 2 - Running satdump-ui
fails
I'm not sure if this should be a separate issue.
Once I've built SatDump with the modifications from above (this time just on master
), running ./satdump-ui
fails with GLFW errors:
[21:14:43 - 10/04/2024] (E) Usage : ./satdump-ui [downlink] [input_level] [input_file] [output_file_or_directory] [additional options as required]
[21:14:43 - 10/04/2024] (E) Extra options (examples. Any parameter used in modules can be used here) :
[21:14:43 - 10/04/2024] (E) --samplerate [baseband_samplerate] --baseband_format [f32/i16/i8/w8] --dc_block --iq_swap
[21:14:43 - 10/04/2024] (E) Glfw Error 65542: GLX: No GLXFBConfigs returned
[21:14:43 - 10/04/2024] (E) Glfw Error 65545: GLX: Failed to find a suitable GLXFBConfig
[21:14:43 - 10/04/2024] (W) Could not init GLFW Window; falling back to OpenGL 2.1...
[21:14:43 - 10/04/2024] (E) Glfw Error 65542: GLX: No GLXFBConfigs returned
[21:14:43 - 10/04/2024] (E) Glfw Error 65545: GLX: Failed to find a suitable GLXFBConfig
[21:14:45 - 10/04/2024] (C) Could not init GLFW Window! Exiting
This seems strange, as glxinfo | grep -i "glxfb"
returns 896 GLXFBConfigs:
.
My laptop has an AMD Ryzen 7 PRO 5850U, glxinfo
also reports OpenGL version string: 4.6 (Compatibility Profile) Mesa 24.0.3
Running with LIBGL_ALWAYS_SOFTWARE=1
does not change anything.
I will admin I'm no expert with NixOS, and this definitely sound like something isn't being passed right for OpenGL to work. This could be trying to run it with the wrong glfw backend (eg, wayland vs xorg) or such.
You should not need to link mbedtls directly, instead NNG should be built as a shared library (which it is not by default), and itself link to mbedtls if enabled. This is most likely why you are having to link against mbedtls directly. I need to do the same on Android as there everything's static (but this won't be supported on standard Linux builds).
@2ck I happened to come across a similarish problem while packaging SatDump for my NixOS machines (at least the linking part, I didn't have any OpenGL issues - satdump-ui works fine for me) today, and I happened to stumble upon this issue.
It seems to be working fine for me on nixpkgs commit 4a6b83b05df1a8bd7d99095ec4b4d271f2956b64
(nixos-unstable)
Here's my solution:
{ config, pkgs, ... }:
let
satdump_version = "1.2.0";
in
{
environment.systemPackages =
let
satdump = with pkgs;
stdenv.mkDerivation rec {
pname = "satdump";
version = satdump_version;
src = fetchgit {
url = "https://github.com/SatDump/SatDump.git";
rev = satdump_version;
sha256 = "sha256-QGegi5/geL5U3/ecc3hsdW+gp25UE9fOYVLFJUo/N50=";
};
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [
# required deps
fftwFloat
libpng
libtiff
jemalloc
volk
(nng.overrideAttrs (old: {
cmakeFlags = old.cmakeFlags ++ [ "-DBUILD_SHARED_LIBS=ON" ];
}))
rtl-sdr-librtlsdr
hackrf
airspy
airspyhf
glfw
gnome.zenity
zstd
# optional hw support
libad9361
libiio
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
];
};
in
[ satdump ];
}