touchHLE: Linux build problems

Building in debug mode on arch linux produces an error:

error: could not find native static library `fmtd`, perhaps an -L flag is missing?

Looking at the code, in case the debug assertions are enabled the linking happens to a debug version of fmt, however it does not seem to exist.

Building in release mode doesn’t work too, because touchHLE links to it statically and static version of fmt is not included on linux too.

I love c++ dependency management I love c++ dependency management I love c++ dependency management

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

Maybe once there’s a GUI or something.

Since this should be easy and quick to build on a typical system though (at least, once the current build issues are fixed), it’s going to be very low on my priority list.

I just wanted to report that I cloned the repo and built (on Arch Linux x86_64). No issues whatsoever, and I launched Crash Nitro Kart 3D and the emulator correctly picked up my Switch Pro Controller and set the right analog to the touch input (so I could touch powerups on the bottom right corner of the screen). I had literally zero issues. The “GUI” works insofar as if I try to launch touchHLE without any .app/.ipa file provided, a GUI error window pops up (as opposed to the app just crashing or erroring out in the terminal).

This project is super cool, I have never owned an iPhone (I personally hate Apple lol) but I love this kind of stuff and I think it’s very cool and game preservation is very important, and I am proficient enough with Linux that I figured I would test it out to see if there were any headaches.

I might be willing to create an AUR package for this (I already am the creator/maintainer of a huge DE port for Regolith DE that is in the AUR, and the maintainer for the AUR package of electronplayer), but I’ll wait to see if a flatpak gets provided first because in that case an AUR package is redundant.

Building the latest master with just cargo build --no-default-features and running ldd on the binary gives:

ldd target/debug/touchHLE
	linux-vdso.so.1 (0x00007ffde7c24000)
	libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0x00007f2a19a45000)
	libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f2a19600000)
	libopenal.so.1 => /usr/lib/libopenal.so.1 (0x00007f2a198b0000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f2a1988b000)
	libm.so.6 => /usr/lib/libm.so.6 (0x00007f2a19513000)
	libc.so.6 => /usr/lib/libc.so.6 (0x00007f2a19329000)
	/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f2a1a98e000)

Hmm, this seems to build fine now in both static and shared configurations!

Static (w/o any flags):

$ ldd target/release/touchHLE
        linux-vdso.so.1 (0x00007ffdea37a000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fcf10c00000)
        libsndio.so.7 => /usr/lib/libsndio.so.7 (0x00007fcf11a29000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fcf11a09000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007fcf10f18000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007fcf10a19000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fcf11aa0000)
        libasound.so.2 => /usr/lib/libasound.so.2 (0x00007fcf1092b000)
        libbsd.so.0 => /usr/lib/libbsd.so.0 (0x00007fcf119f1000)
        libmd.so.0 => /usr/lib/libmd.so.0 (0x00007fcf119e4000)

Dynamic (--no-default-features):

ldd target/release/touchHLE                                                                                                                                                                                                                             7.1s  Sun 26 Mar 2023 05:43:40 PM MSK
        linux-vdso.so.1 (0x00007ffdf35ca000)
        libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0x00007f0594829000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f0594400000)
        libopenal.so.1 => /usr/lib/libopenal.so.1 (0x00007f05946ae000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f05950bb000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007f0594318000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007f0594131000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007f059513e000)

Linux isn’t really a single platform in the way Windows or macOS are, and I have no idea how to handle the instability of popular distros’ ABIs. For that reason, I’m probably not going to release any Linux builds for the time being, sorry. I’m willing to make some fixes so it’s easier to build though. If you really want a pre-built binary, I recommend trying the Windows one in some flavour of WINE.

Just to be less ambiguous, here’s a diff:

diff --git a/src/cpu/dynarmic_wrapper/build.rs b/src/cpu/dynarmic_wrapper/build.rs
index e008e37..6b9b100 100644
--- a/src/cpu/dynarmic_wrapper/build.rs
+++ b/src/cpu/dynarmic_wrapper/build.rs
@@ -67,11 +67,12 @@ fn main() {
             .join("build/externals/fmt")
             .join(build_type_windows()),
     );
-    link_lib(if cfg!(debug_assertions) {
-        "fmtd"
-    } else {
-        "fmt"
-    });
+    println!("cargo:rustc-link-lib=dylib={}", "fmt");
+    //link_lib(if cfg!(debug_assertions) {
+    //    "fmtd"
+    //} else {
+    //    "fmt"
+    //});
     link_search(
         &dynarmic_out
             .join("build/externals/mcl/src")
diff --git a/src/audio/openal_soft_wrapper/build.rs b/src/audio/openal_soft_wrapper/build.rs
index d12716a..f60c074 100644
--- a/src/audio/openal_soft_wrapper/build.rs
+++ b/src/audio/openal_soft_wrapper/build.rs
@@ -32,6 +32,7 @@ fn main() {
     } else {
         "openal"
     });
+    println!("cargo:rustc-link-lib=dylib=sndio");
     // rerun-if-changed seems to not work if pointed to a directory :(
     //rerun_if_changed(&workspace_root.join("vendor/openal-soft"));
 }
diff --git a/Cargo.toml b/Cargo.toml
index 9845461..f91339f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,7 +34,7 @@ rusttype = "0.9.3"
 # sdl2 crates pinned at 0.35.1 because static linking seems to be broken for
 # 0.35.2 on macOS (build errors about undefined symbols for
 # _CHHapticDynamicParameterIDHapticIntensityControl etc)
-sdl2 = { version = "=0.35.1", features = ["bundled", "static-link"] }
+sdl2 = { version = "=0.35.1", features = [] }
 sdl2-sys = "=0.35.1"
 touchHLE_dynarmic_wrapper = { path = "src/cpu/dynarmic_wrapper" }
 touchHLE_gl_bindings = { path = "src/window/gl_bindings" }

Cargo.toml changes

# sdl2 crates pinned at 0.35.1 because static linking seems to be broken for
# 0.35.2 on macOS (build errors about undefined symbols for
# _CHHapticDynamicParameterIDHapticIntensityControl etc)
sdl2 = { version = "=0.35.1" }
sdl2-sys = "=0.35.1"

Not everyone is as familiar with rust 😛 Finally got it working.

I’m going to add a feature that lets you dynamically link most of the dependencies at some point, since a friend of mine told me that would be useful on Linux.