Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on Haiku (OS) #2

Open
victroniko opened this issue Feb 6, 2023 · 25 comments
Open

Building on Haiku (OS) #2

victroniko opened this issue Feb 6, 2023 · 25 comments

Comments

@victroniko
Copy link

Hello there!

I'm on a quest for building and making rtl-sdr work on Haiku, AFAIK no one had tried it before. After fiddling a bit I've built and ran it (more or less) succesfully with autotool, from the original OSMOCOM repos. Sadly it doesn't build at all with cmake.

This fork looks really interesting and I want to port this one to Haiku, instead of the original... but it also fails to build with cmake, with the exact same error:

...
[ 75%] Linking C executable rtl_test
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: cannot find -lrt
collect2: error: ld returned 1 exit status
src/CMakeFiles/rtl_test.dir/build.make:99: recipe for target 'src/rtl_test' failed

With autotool, the script checks if function clock_gettime is available and fails gracefully when it's not, which allows the build to continue. OTOH, cmake forces the -lrt flag always, and bails out when it finds librt (which provides clock_gettime) isn't available.

Thing is, in Haiku librt does not exist. clock_gettime equivalent functionality resides in libroot (/system/lib/libroot.so)

Is it possible to add a provision for checking the target platform, and if it's Haiku then use libroot instead of librt? Maybe it's trivial but I fear it's a bit out of my coding knowledge, as I looked and fiddled w/many files (ie. CMakeLists.txt) with no success.

Here's a pic of rtl_test running on Haiku, to demonstrate a working build:

rtlsdr_rtl-test

@Mr-Precise
Copy link
Owner

I have never used this OS
I will try to install haiku os soon and I'll try to fix it

@Mr-Precise
Copy link
Owner

Mr-Precise commented Feb 6, 2023

Build fixed.
Can you check the build from devel branch (before I push this change to main)?
git clone https://github.com/Mr-Precise/rtl-sdr/ -b devel

@Mr-Precise
Copy link
Owner

Mr-Precise commented Feb 6, 2023

ohh
I have the same problem on Windows
bind ip broken in rtl_tcp afrer add IPv6 support
rtl_tcp
...although it works fine on Linux & macOS

@Mr-Precise
Copy link
Owner

Mr-Precise commented Feb 6, 2023

I created haiku branch based on main-win + CMake fix
Or will have to use haiku branch or full remove IPv6 support from rtl_tcp and use old code c1aed9f

old

@victroniko
Copy link
Author

victroniko commented Feb 7, 2023

I can confirm haiku branch builds and works ok on Haiku x86_64.

Note that it fails at make install step: seems paths are hardcoded to install to /boot/system and this won't do, as Haiku sys-dirs are read only. (Packages are built in a simulated environment, and ideally scripts should use syscalls to find the various dirs like bin, lib etc.) However, this step isn't necessary because I'm using haikuporter to make a ready-to-use binary package. I can use the tool abstractions for the various install paths, like this:

screenshot2
build-ok

re: IPv6, at least for Haiku target I think it can be safely ignored/disabled for now.

@Mr-Precise
Copy link
Owner

Mr-Precise commented Feb 7, 2023

I think I completely fixed the problem with binding to IP/IPv6 in Windows & Haiku OS.
All changes moved to main.
image
Install path - In the process of testing. I will try to fix it

@Mr-Precise
Copy link
Owner

Mr-Precise commented Feb 7, 2023

I still don't understand how to install without creating a package
google knows little about cmake on haiku
cmake .. -DCMAKE_INSTALL_PREFIX=/system/non-packaged works... what

@victroniko
Copy link
Author

victroniko commented Feb 7, 2023

I asked Haiku devs, they say cmake scripts should follow GnuInstallDirs setup. This improves portability, and your fork will build not only on Haiku but also every OS that follows GNU standard install dirs.

edit. full dev answer here with tips on how to do a local install (which is more for testing, really not needed for packaging).

@Begasus
Copy link

Begasus commented Feb 9, 2023

Is there a way to disable the build/install for the static library? (couldn't find an option with cmake -L)

@Mr-Precise
Copy link
Owner

Mr-Precise commented Feb 9, 2023

@Begasus
I probably implemented what you wanted.
Use -DINSTALL_STATIC_LIB=NO
To do this, it is better to use a feature request.

@Begasus
Copy link

Begasus commented Feb 9, 2023

Thanks! That worked out ok :) didn't want to step in before @victroniko made a PR for this, already commented on the forum thread reported earlier here to fix the install paths. Can't check this in other OS's but I think it should be ok (if you got some time to look into that).

@victroniko
Copy link
Author

victroniko commented Feb 13, 2023

@Begasus I'll be a bit low on time next week, if you want/can do a PR then please go ahead, no worries :)

@Mr-Precise ATM dev branch builds ok (inside haikuporter) with this:
cmake -DCMAKE_BUILD_TYPE=Release -DINSTALL_STATIC_LIB=NO -Bbuild $cmakeDirArgs

$cmakeDirArgs is just something we use for building w/haikuporter, don't worry about it.

edit. If dev branch builds OK on other platforms too, then we're all set.

@Begasus
Copy link

Begasus commented Feb 13, 2023

@victroniko main branch builds fine here, posted a reply in the forum with the recipe I tested just a few minutes ago :)

@Mr-Precise
Copy link
Owner

Can you check for compatibility after recent changes?

@victroniko
Copy link
Author

One last push: GNUInstallDirs setup needs to live before install options, otherwise CMake won't pick it up.

--- CMakeLists.txt      2023-02-14 14:56:24.043515904 -0300
+++ CMakeLists.txt.diff 2023-02-21 23:46:52.618397696 -0300
@@ -42,6 +42,12 @@
 include(GenerateExportHeader)
 include(CMakePackageConfigHelpers)
 
+# Set paths early according to GNUInstallDirs (fixes Haiku build)
+set(prefix "${CMAKE_INSTALL_PREFIX}")
+set(exec_prefix \${prefix})
+set(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR})
+set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
+
 # Set the version information here
 set(VERSION_INFO_MAJOR_VERSION 2023) # increment major on api compatibility changes
 set(VERSION_INFO_MINOR_VERSION 2) # increment minor on feature-level changes
@@ -198,11 +204,6 @@
     UNSET(RTLSDR_PC_LIBS)
 ENDIF(CMAKE_CROSSCOMPILING)
 
-set(prefix "${CMAKE_INSTALL_PREFIX}")
-set(exec_prefix \${prefix})
-set(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR})
-set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
-
 CONFIGURE_FILE(
     ${CMAKE_CURRENT_SOURCE_DIR}/librtlsdr.pc.in
     ${CMAKE_CURRENT_BINARY_DIR}/librtlsdr.pc

With this, main branch builds perfect in Haiku :D

@Mr-Precise
Copy link
Owner

It seems to work well through Virtualbox...
vboxhaiku

@victroniko
Copy link
Author

Main branch now builds OK on Haiku x86_64, confirmed!


OTOH, on x86_32... it doesn't find libusb, but it is clearly installed:

Captura

Pointing pkg_search_modules() to libusb_x86 doesn't seem to work. @Begasus can you lend us a hand? I'm a bit lost how to pass _x86 Haiku libs to Cmake...

@Begasus
Copy link

Begasus commented Feb 22, 2023

You probably have to switch compiler (don't have Haiku running atm) for 32bit, in Terminal type: setarch x86 (this will switch compiler from gcc2.* to gcc11.*), then try again. :) (exit will get you back to gcc2 (you can also check with gcc -v in Terminal which one is being used))

@victroniko
Copy link
Author

victroniko commented Feb 24, 2023

Switched architecture, no luck... I'll ask on Haiku forums and report back here.

btw. Falkon browser is very unstable - use Web (ex Ephiphany) instead.

@Begasus
Copy link

Begasus commented Feb 24, 2023

Just checked out the latest commit on main and it's still building OK with haikuports here: Begasus/haikuports@59bba25

EDIT building from Terminal works fine too:

rtl-sdr

@victroniko
Copy link
Author

On x86_64 it builds fine, both w/ haikuporter and from terminal.

Building on x86_gcc11 is what doesn't work for me. As it appears to be something on Haiku side, i'll better ask in the forum :)

@Mr-Precise
Copy link
Owner

I will install the 32 bit version of haiku soon and try to check and fix
Just a little later, I'm sick

@Mr-Precise
Copy link
Owner

Screenshot_20230225_165744
🙂

@Mr-Precise
Copy link
Owner

I released version 2023.8.25.
Change log rtl-sdr/releases/v2023.8.25
I think this is enough to update in haikuports.

@Begasus
Copy link

Begasus commented Sep 22, 2023

Did a quick check, still builds and package fine on 64bit, can't check it myself as I don't have any supported devices though.
Will do an update tomorrow for this @victroniko if you can could you check it out and report back?

EDIT: pushed the changes, will check in the morning if both arches were build fine on our buildmasters.
Updated PR's haikuports/haikuports#9505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants