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

unable to build on gnu/linux with portaudio jack backend #403

Open
CastixGitHub opened this issue May 22, 2021 · 6 comments · May be fixed by #410
Open

unable to build on gnu/linux with portaudio jack backend #403

CastixGitHub opened this issue May 22, 2021 · 6 comments · May be fixed by #410

Comments

@CastixGitHub
Copy link

Hello again,
In commit 55b47d7
the compile option to disable jack support disappeared
anyway, I get a bunch of undefined references.
My installed version of jack is jack2-1.9.18-1 with linux 5.12.4

I would be happy to get jack support, but even disabling it is ok for me.
reporting here even if the bug seems upstream to make it known

[ 33%] Built target portaudio_static
CMake Warning at /home/castix/personal/extempore-aur/src/extempore/extras/cmake/download_assets.cmake:13 (message):
  Directory /home/castix/personal/extempore-aur/src/extempore/assets already
  exists - skipping asset dowload step


[ 33%] Built target assets
Consolidate compiler generated dependencies of target pcre
[ 38%] Built target pcre
Consolidate compiler generated dependencies of target extempore
[ 38%] Linking CXX executable extempore
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `IsFormatSupported':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:920: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:920: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:920: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `GetStreamTime':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1740: undefined reference to `jack_frame_time'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1740: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `UpdateQueue':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1429: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `RealProcess':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1351: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1367: undefined reference to `jack_frame_time'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1369: undefined reference to `jack_port_get_latency'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1372: undefined reference to `jack_port_get_latency'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1394: undefined reference to `jack_port_get_buffer'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1405: undefined reference to `jack_port_get_buffer'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `JackCallback':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1564: undefined reference to `jack_port_get_buffer'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `CleanUpStream':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:985: undefined reference to `jack_port_unregister'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:990: undefined reference to `jack_port_unregister'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `Terminate':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:822: undefined reference to `jack_deactivate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:827: undefined reference to `jack_client_close'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `OpenStream':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1082: undefined reference to `jack_port_name_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1083: undefined reference to `jack_client_name_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1089: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1183: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1216: undefined reference to `jack_port_name_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1217: undefined reference to `jack_port_register'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1226: undefined reference to `jack_port_name_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1227: undefined reference to `jack_port_register'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1267: undefined reference to `jack_get_ports'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1271: undefined reference to `jack_port_by_name'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1312: undefined reference to `jack_frame_time'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1243: undefined reference to `jack_get_ports'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1247: undefined reference to `jack_port_by_name'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1307: undefined reference to `jack_port_get_latency'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1308: undefined reference to `jack_get_buffer_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1303: undefined reference to `jack_port_get_latency'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1304: undefined reference to `jack_get_buffer_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `RealStop':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1690: undefined reference to `jack_port_connected'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1692: undefined reference to `jack_port_disconnect'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1698: undefined reference to `jack_port_connected'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1700: undefined reference to `jack_port_disconnect'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `StartStream':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1611: undefined reference to `jack_port_name'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1611: undefined reference to `jack_port_name'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1611: undefined reference to `jack_connect'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1621: undefined reference to `jack_port_name'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1621: undefined reference to `jack_port_name'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1621: undefined reference to `jack_connect'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `PaJack_Initialize':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:735: undefined reference to `jack_client_open'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `BuildDeviceList':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:493: undefined reference to `jack_client_name_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:494: undefined reference to `jack_client_name_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:501: undefined reference to `jack_get_ports'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:560: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:591: undefined reference to `jack_get_ports'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:612: undefined reference to `jack_get_ports'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `PaJack_Initialize':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:802: undefined reference to `jack_client_close'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `BuildDeviceList':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:598: undefined reference to `jack_port_by_name'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:600: undefined reference to `jack_port_get_latency'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:619: undefined reference to `jack_port_by_name'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:621: undefined reference to `jack_port_get_latency'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `PaJack_Initialize':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:783: undefined reference to `jack_on_shutdown'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:784: undefined reference to `jack_set_error_function'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:785: undefined reference to `jack_get_buffer_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:787: undefined reference to `jack_set_sample_rate_callback'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:788: undefined reference to `jack_set_xrun_callback'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:789: undefined reference to `jack_set_process_callback'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:790: undefined reference to `jack_activate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `BuildDeviceList':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:560: undefined reference to `jack_get_sample_rate'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `PaJack_SetClientName':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1752: undefined reference to `jack_client_name_size'
/usr/bin/ld: /home/castix/personal/extempore-aur/src/build/portaudio/lib/libportaudio.a(pa_jack.c.o): in function `PaJack_GetClientName':
/home/castix/personal/extempore-aur/src/build/portaudio/src/portaudio_static/src/hostapi/jack/pa_jack.c:1767: undefined reference to `jack_get_client_name'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/extempore.dir/build.make:337: extempore] Error 1
make[1]: *** [CMakeFiles/Makefile2:877: CMakeFiles/extempore.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

I've done a patch for adding back the option in the aur package, feel free to merge it

--- CMakeLists.txt	2021-05-22 11:30:27.958294663 +0200
+++ CMakeLists.txt.new	2021-05-22 11:29:17.120943327 +0200
@@ -14,6 +14,8 @@
 
 option(EXT_DYLIB "build extempore as a dynamic library" OFF)
 
+option(JACK "use the Jack Portaudio backend" ON)
+
 ## this is useful because we can group targets together (e.g. all the AOT libs)
 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 
@@ -186,6 +188,7 @@
   -DPA_BUILD_STATIC=ON
   -DPA_BUILD_SHARED=OFF
   -DPA_LIBNAME_ADD_SUFFIX=OFF
+  -DPA_USE_JACK=${JACK}
   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
   -DCMAKE_C_FLAGS=${EXT_DEPS_C_FLAGS}
   -DCMAKE_CXX_FLAGS=${EXT_DEPS_CXX_FLAGS}
@CastixGitHub
Copy link
Author

I had to apply the same patch on trisquel.info where jack was not installed at all
Should the jack option be OFF by default?

@CastixGitHub CastixGitHub changed the title unable to build on archlinux with portaudio jack backend unable to build on gnu/linux with portaudio jack backend May 22, 2021
@benswift
Copy link
Collaborator

Hey @CastixGitHub yep, thanks - that commit you reference was a quick fix (for #393 ) and it wasn't a principled "Extempore Jack is dead" thing. So since you've got a patch which adds it back I'll restore the build option (OFF by default, as you suggest).

Having said that, it's still true that neither @digego or I are using Jack, so it may well not work. If you find any issues, we'd happily apply any more patches.

@eihli
Copy link

eihli commented Aug 10, 2021

Thanks for submitting this issue. I just experienced the same problem.

I'm not familiar with cmake, but by mucking about I fixed it on my machine by adding -ljack to the end of CMakeFiles/extempore.dir/link.txt. Is that effectively what DPA_USE_JACK=${JACK} is doing?

@CastixGitHub
Copy link
Author

@eihli I'm not sure about you question, I'll try anyway t reply

I see that the portaudio code have "a sort of adapter" (hostapi) between backends, the jack one is pa_jack.c and includes the headers from jack

#include <jack/types.h>
#include <jack/jack.h>

and I'm not a C programmer, I don't know from where these header files are found by the compiler and where are installed (not true, it's POSIX)
anyway I can say that portaudio cmake file looks for jack,
if found links jack to portaudio and builds that pa_jack.c and .h
https://github.com/PortAudio/portaudio/blob/093d7f7fdf2cd1dbed0cb888257b6b39b4bed7db/CMakeLists.txt#L91
and about that link, https://cmake.org/cmake/help/latest/command/target_link_libraries.html (search for -lfoo) it does also so, then it sets PA_USE_JACK to 1
and the only place in portaudio where PA_USE_JACK is used seems here https://github.com/PortAudio/portaudio/blob/147dd722548358763a8b649b3e4b41dfffbcfbb6/src/os/unix/pa_unix_hostapis.c#L82 to initialize pa_jack

now I mean, in my situation jack was found by cmake, and tried to build against it, and failed.
I had jack2 installed through cadence, on archlinux. then with the patch above i told portaudio to avoid initializing jack, even if the jack support was built? I'm not getting how I managed to get it working.
portaudio links jack here https://github.com/PortAudio/portaudio/blob/2dc8b6eb17ac5fda1f89722cfa0889bfc6e73434/cmake/modules/FindJACK.cmake#L65 when found,

I also tested extempore with pipewire's implementation of jack, that is also found by portaudio (here's proof https://github.com/PortAudio/portaudio/blob/2dc8b6eb17ac5fda1f89722cfa0889bfc6e73434/cmake/modules/FindJACK.cmake#L17) and it seems to work well (built with the patch above, I did't test without it) (tested with pw-jack, not the dropin replacement) (I'm not suggesting you to use pipewire)

small resume of the current jack implementations:
jack implemented in C
jack2 implemented in C++
pipewire implemented in C
not considering about netjack, jack on windows and so on.
them share the same protocol and is strongly discouraged to mix them
I am pretty sure that extempore/portaudio works with jack C implementation, that's defined in the extempore guix package, and the guix community dosn't see any advantage of using jack2 instead of jack

Happy to see your issue is also solved anyway

@benswift
Copy link
Collaborator

@CastixGitHub @eihli thanks again for looking into the Jack stuff.

I'm open to a PR which re-adds the Jack support (as long as it doesn't complicate the setup for other backends). @eihli adding -ljack to the file you mentioned isn't ideal (since that's an auto-generated CMake file) but we could add it via target_link_libraries() or something to make it a bit more seamless (hidden behind a guard based on the the top-level JACK option, obviously).

One of the other tricks is adding "does Extempore support this audio backend" to the test suite. Extempore's test suite (which runs automatically in a GH action on push) has to run with the --noaudio dummy audio device, because the CI runners used by GH actions don't have any real devices to use. So we can't actually test the audio devices in the CI setup (although you could add tests and run them on e.g. your local machine).

Anyway, I think what I'm suggesting is that if you do (a) find a nice way to add the Jack support back in (again, using the JACK CMake config option that is mentioned in the CMakeLists.txt file) and (b) could confirm that it works, then I'd accept the pull request :)

@benswift
Copy link
Collaborator

One other thing - unfortunately I'm in lockdown at the moment and only have my MBP with me (my linux machine is still at work, and not remotely accessible 😭 ). So I'm limited in my ability to test Jack stuff at the moment (although others will be able to test it - you could also ask for testing help on the mailing list).

archlinux-github pushed a commit to archlinux/aur that referenced this issue Aug 2, 2022
@CastixGitHub CastixGitHub linked a pull request Oct 25, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants