touchHLE
touchHLE copied to clipboard
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~~
What worked for me was using just println!("cargo:rustc-link-lib=dylib=fmt");
Maybe these horrors could be alleviated by providing a musl statically-linked version of touchHLE
Other problems:
on linux openal depends on sndio
it seems. Only shared on linux. Hacked by adding println!("cargo:rustc-link-lib=dylib=sndio");
to src/audio/openal_soft_wrapper/build.rs
. Maybe a better solution would be to use pkg-config to discover dependencies on linux
sdl2 before some version (and the version bundled with sdl2 crate seems to be older) fails to link with never wayland: https://github.com/libsdl-org/SDL/pull/5092/files. Fixed by disabling bundled
and static-link
features of sdl2
After these hacks I can build touchHLE on arch linux and run Super Monkey Ball =)
Nice!
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.
since a friend of mine told me that would be useful on Linux.
Yeah, this is kinda expected of local builds, especially for apps with GUI
@DCNick3 I tried adding it at the end of the file and get this error. Where does it need to go?
Compiling touchHLE_gl_bindings v0.1.0 (/home/deck/build/touchHLE/src/window/gl_bindings)
Compiling touchHLE_openal_soft_wrapper v0.1.0 (/home/deck/build/touchHLE/src/audio/openal_soft_wrapper)
Compiling touchHLE_stb_image_wrapper v0.1.0 (/home/deck/build/touchHLE/src/image/stb_image_wrapper)
error: macro expansion ignores token `{` and any following
--> /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/macros.rs:135:23
/rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/macros.rs:136:1
/rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/macros.rs:137:5
|
::: src/audio/openal_soft_wrapper/build.rs:38:1
|
38 | println!("cargo:rustc-link-lib=dylib=sndio");
| -------------------------------------------- caused by the macro expansion here
|
= note: the usage of `println!` is likely invalid in item context
error: could not compile `touchHLE_openal_soft_wrapper` due to previous error
warning: build failed, waiting for other jobs to finish...
^C Building [==============> ] 87/145: sdl2-sys(build) ```
And where does the prntln line for fmt go?
Ok so
src/cpu/dynarmic_wrapper/build.rs
fn link_lib(lib: &str) {
println!("cargo:rustc-link-lib=static={}", lib);
println!("cargo:rustc-link-lib=dylib=fmt");
}
and src/audio/openal_soft_wrapper/build.rs
fn link_lib(lib: &str) {
println!("cargo:rustc-link-lib=static={}", lib);
println!("cargo:rustc-link-lib=dylib=sndio");
}
Got me past the errors but I'm back to SDL2 Wayland issue from #8
@DCNick3 Where do the SDL2 changes you mentioned need to go?
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 :P Finally got it working.
Strangely release built with those changes but debug goes back to failing on fmt error
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" }
Great :) could we have a first linux build for the release section?
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.
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.
@hikari-no-yume If you are not aware about this, I recommend packaging your app as a Flatpak. With Flatpaks, you don't need to worry about Distro specific stuff (think of it like Docker, but for GUI applications).
I can contribute Flatpak packaging stuff if you want, as I was playing around with them recently.
@DCNick3 Thank you! Debug works as well with that patch.
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.
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)
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)