RTL-SDR support

It’s not about their own error codes, but about the places where they use errno.

For example this is found in some software and is problematic:

// This function return a positive value on success, and a negative one in case of errors
int someFunction() {
    ... // call some POSIX function that sets errno

    if (error)
        return -errno; // this doesn't work on Haiku because errno will be negative so -errno will be positive.
}

If the code you’re working with isn’t doing things like this with errno, you should be fine.

Update time.

My recipe builds fine with autotools, but I ran into a weird outcome. Stopping rtl_sdr with Ctrl+C does not quit nicely but rather pops-up the “app crash” dialog, while still trying to access the USB stack. This fills the terminal w/timeout errors. Choosing “terminate” ultimately kills the thread.

I used autotools because of familiarity, but rtl_sdr can be built with cmake too. Looking at the Windows build filenames makes me believe they use cmake with -DCMAKE_BUILD_TYPE=RelWithDebInfo by default for all platforms.

Would building with -DCMAKE_BUILD_TYPE=Release (or MinRel) help fix such behavior in this case?

edit. BTW thank you @waddlesplash for the commit removing the old play command! :slight_smile:

No, it will just remove debug info (which allow to identify the file, line and function where a thing crashed) and make things harder to investigate. But the software behavior will be the same.

Baby steps… The cmake scripts want to install everything to hardcoded /boot/system, this obviously doesn’t work.

cmake-err

In haikuporter we can pass these vars instead, but I don’t see one to abstract the system dir. It would’ve been nice to do something like make install DESTDIR=$sysDir and call it a day.

The way I see it, there are 3 options:

  1. Find a way to build the recipe without modifying original scripts.

  2. Ask mantainer(s) to modify rtl_sdr install scripts, to take Haiku into account and do a proper install - this I’m not sure they’ll see as worthy of their time, but I can try.

  3. If all else fails, a manual INSTALL() by hand? ie. install -d $libDir some_libs and iterate for bin, includes etc – took a look at some recipes and it’s doable, if a bit ugly.

Unless there is a better way?


(BTW - why insist on cmake if rtl_sdr built fine with autotools? Because it’s a stable library, but development stagnated long time ago and it’s on maintenance mode now. There are newer, better mantained forks with more features, and the one I’m trying to build dropped autotools support.)

Actually the 2) way is : Modifying the cmake script to be more flexible and upstream it.

If the recipe properly uses CMake and in particular the GnuInstallDirs setup, this should work just fine. You indeed need to specify several directories. In your example error, it’s trying to create an “include” directory where in Haiku this should be “headers”

You also need to set CMAKE_INSTALL_PREFIX to point to the appropriate place ($prefix in haikuports, or /boot/system/non-packaged if you want to install locally for example).

In the case of haikuporter, the only thing you really need to do is to pass $cmakeDirArgs to cmake when invoking it in the recipe. If this doesn’t work, it means the CMakeLists were not written using the best practises and they should be improved to work in that case.

1 Like

I asked the fork maintainer to look at this, he seems eager to support Haiku. In the meanwhile option 3 builds properly - but 1st I’ll wait for him to fix cmake build, before PRing a recipe.

I’m still learning how to git around (pun intended :slight_smile:), do upstreams and such. Next ports I hope to be able to patch things and do a bit of actual coding if needed.

My main goal is to completely port SDR++ to Haiku, so I have a lot to learn.

2 Likes

$includeDir, $libDir and $binDir don’t need $secondaryArchSuffix, this is done by haikuporter when doing a build for 32bit. Haven’t looked at the source (could you link it?), without meaningfull comments :slight_smile:

1 Like

I saw it done like that in other recipes, so I just went along. Thank you for the tip!

Click for actual sources (might change at any moment, though)

1 Like

Nice panel & menu BG color :slightly_smiling_face:, what values did you use?

Could you point to some of them? That shouldn’t be needed afaik. :slight_smile:

EDIT from a quick look at theire cmakefiles I gues it’s ok to use $cmakeDirArgs in the BUILD secion?

EDIT2 this is the problem: https://github.com/Mr-Precise/rtl-sdr/blob/main/include/CMakeLists.txt#L26
it doesn’t use CMAKE_INSTALL_INCLUDEDIR there.
Same here: rtl-sdr/CMakeLists.txt at fc3f2133e23ddd02d7e582bfa2c2d2f2edd96ce5 · Mr-Precise/rtl-sdr · GitHub

Hey!

I have both an RTL-SDR dongle, and an Airspy-Mini (a better performing SDR dongle) that I used to use for HAM radio band listening with a Spyverter (just an RF upconverter).

So… while I can’t be of much use developing right now, i’d be happy in the coming days/weeks to do any testing you would like? I’d personally LOVE to use haiku for radio stuff. Admittedly i’m somewhat out of the loop on radio these days, but i think using these things in haiku would certainly rekindle the interest.

Good luck, and well done so far on ya progress!

John

2 Likes

This fixes the build and install for me on 32bit with cmake:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23e23b8..c7c8c72 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -142,7 +142,7 @@ endif (ENABLE_ZEROCOPY)
 install(FILES
     include/rtl-sdr.h
     include/rtl-sdr_export.h
-    DESTINATION include
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 )
 
 ########################################################################
@@ -175,8 +175,8 @@ ENDIF(CMAKE_CROSSCOMPILING)
 
 set(prefix "${CMAKE_INSTALL_PREFIX}")
 set(exec_prefix \${prefix})
-set(includedir \${prefix}/include)
-set(libdir \${exec_prefix}/lib)
+set(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR})
+set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
 
 CONFIGURE_FILE(
     ${CMAKE_CURRENT_SOURCE_DIR}/librtlsdr.pc.in
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 507c0c7..ec60649 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -23,5 +23,5 @@
 install(FILES
     rtl-sdr.h
     rtl-sdr_export.h
-    DESTINATION include
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
 )
-- 
2.37.3
2 Likes

Good catch!

Life and work got in the way, I’m kinda busy with all sort of things… hopefully this weekend I’ll have a bit of energy to continue this quest.

Look for the “nucleo” theme in ThemeManager :wink:

The “patch” got upstreamed in the devel branch, if things are OK there for other OS’s it should be good to go to move into master branch, less patching involved then :slight_smile:

1 Like

Okay, cmake build from dev branch looks good now. Let’s wait for him pushing to main and I’ll finish the recipe. In the meantime here’s a draft for review & testing, please comment and correct any mistakes I made:

Oh and btw, a lil’ sneak peek…

The 1st ever FM-radio recording done in Haiku with rtl_sdr :slight_smile: (lacks filtering and stuff, these are generally done in end-user SDR apps).

2 Likes

Would be nicer if you submitted the PR for testing instead, the knowledgeable parties will then see it and comment on it :slight_smile:

1 Like

For what it’s worth, this is the work I’ve done so far (patch got upstreamed and is in main branch there, so took the latest commit as srcGitRev): sdl-sdr, add recipe · Begasus/haikuports@27b0c22 · GitHub

Maybe need some tlc, but so far it’s building fine for me :slight_smile:

Weeell it builds fine and all but I wanted some pre-input, you know being my 1st recipe ever… I know PRs are exactly for that but ehh, I’m shy :melting_face:

@Begasus you ok if I take some bits from yours? Namely the _devel entries (re)ordering… the rest I actually want to be corrected the proper way when doing the PR, to learn the do and dont’s.

@victroniko no problem, when it hits haikuports we will have a look at it :wink: