adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
531 stars 125 forks source link

[simpleaudio] problem compiling with ldc2 under linux #359

Closed TheZipCreator closed 1 year ago

TheZipCreator commented 1 year ago

I'm trying to compile arsd.simpleaudio with ldc2/dub on linux and I'm getting the following errors:

Performing "debug" build using /home/z/things/compilers/ldc2/bin/ldc2 for x86_64.
arsd-official:simpleaudio 10.9.8: building configuration "library"...
/home/z/things/compilers/ldc2/bin/../import/core/sys/posix/sys/types.d(685,11): Error: undefined identifier `c_ulong`
/home/z/things/compilers/ldc2/bin/../import/core/sys/posix/sys/types.d(661,40): Error: undefined identifier `__SIZEOF_PTHREAD_MUTEX_T`
/home/z/things/compilers/ldc2/bin/../import/core/sys/posix/sys/types.d(662,16): Error: undefined identifier `c_long`
/home/z/things/compilers/ldc2/bin/../import/core/thread/threadbase.d(85,23): Error: template instance `core.internal.traits.classInstanceAlignment!(Mutex)` error instantiating
/home/z/things/compilers/ldc2/bin/ldc2 failed with exit code 1.

Not sure if this is an ldc2 bug or a simpleaudio bug.

adamdruppe commented 1 year ago

It is a compiler regression bug:

https://issues.dlang.org/show_bug.cgi?id=23595

With a possible fix not merged:

https://github.com/dlang/dmd/pull/14826

You can work around it by changing the order of imports in a all-at-once build. I don't know if dub will let you do that but maybe editing the file to import something else first will trick it.

TheZipCreator commented 1 year ago

ah. I've moved it into my project instead of importing it as a dependency and now I get this error instead, which may actually be a problem with simpleaudio.d:

Performing "debug" build using /home/z/things/compilers/ldc2/bin/ldc2 for x86_64.
bloqq ~master: building configuration "application"...
Linking...
/usr/bin/ld: .dub/build/application-debug-linux.posix-x86_64-ldc_v1.30.0-5E1DB52313F78E46745920055EEB0576/bloqq.o: in function `silence_alsa_messages':
/home/z/code/d/bloqq/source/arsd/simpleaudio.d:3119: undefined reference to `snd_lib_error_set_handler'
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1
/home/z/things/compilers/ldc2/bin/ldc2 failed with exit code 1.

commenting out the function call snd_lib_error_set_handler(&alsa_message_silencer) appears to fix it and it compiles with no errors (yay!) but there's probably a better solution.

EDIT: ... or it doesn't work. Actually trying to use the library (literally just constructing a single AudioOutputThread causes the following:

Performing "debug" build using /home/z/things/compilers/ldc2/bin/ldc2 for x86_64.
bloqq ~master: building configuration "application"...
Linking...
/usr/bin/ld: .dub/build/application-debug-linux.posix-x86_64-ldc_v1.30.0-5E1DB52313F78E46745920055EEB0576/bloqq.o: in function `_D4arsd11simpleaudio11AudioOutput4playMFZv':
/home/z/code/d/bloqq/source/arsd/simpleaudio.d:2054: undefined reference to `snd_pcm_wait'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2057: undefined reference to `snd_pcm_recover'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2068: undefined reference to `snd_pcm_avail_update'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2088: undefined reference to `snd_pcm_writei'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2091: undefined reference to `snd_pcm_recover'
/usr/bin/ld: .dub/build/application-debug-linux.posix-x86_64-ldc_v1.30.0-5E1DB52313F78E46745920055EEB0576/bloqq.o: in function `_D4arsd11simpleaudio11AudioOutput5closeMFZv':
/home/z/code/d/bloqq/source/arsd/simpleaudio.d:2235: undefined reference to `snd_pcm_close'
/usr/bin/ld: .dub/build/application-debug-linux.posix-x86_64-ldc_v1.30.0-5E1DB52313F78E46745920055EEB0576/bloqq.o: in function `_D4arsd11simpleaudio11openAlsaPcmFEQBhQBf16snd_pcm_stream_tiiAyaZPSQCnQCl9snd_pcm_t':
/home/z/code/d/bloqq/source/arsd/simpleaudio.d:2854: undefined reference to `snd_pcm_open'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2860: undefined reference to `snd_pcm_hw_params_malloc'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2865: undefined reference to `snd_pcm_hw_params_any'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2869: undefined reference to `snd_pcm_hw_params_set_access'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2872: undefined reference to `snd_pcm_hw_params_set_format'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2877: undefined reference to `snd_pcm_hw_params_set_rate_near'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2882: undefined reference to `snd_pcm_hw_params_set_channels'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2887: undefined reference to `snd_pcm_hw_params_set_periods_near'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2893: undefined reference to `snd_pcm_hw_params_set_buffer_size_near'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2898: undefined reference to `snd_pcm_hw_params'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2904: undefined reference to `snd_pcm_sw_params_malloc'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2908: undefined reference to `snd_pcm_sw_params_current'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2910: undefined reference to `snd_pcm_sw_params_set_avail_min'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2912: undefined reference to `snd_pcm_sw_params_set_start_threshold'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2914: undefined reference to `snd_pcm_sw_params'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2919: undefined reference to `snd_pcm_prepare'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2907: undefined reference to `snd_pcm_sw_params_free'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2863: undefined reference to `snd_pcm_hw_params_free'
/usr/bin/ld: /home/z/code/d/bloqq/source/arsd/simpleaudio.d:2857: undefined reference to `snd_pcm_close'
/usr/bin/ld: .dub/build/application-debug-linux.posix-x86_64-ldc_v1.30.0-5E1DB52313F78E46745920055EEB0576/bloqq.o: in function `_D4arsd11simpleaudio13AlsaException6__ctorMFAyaiQemC6object9ThrowableZCQCrQCpQCf':
/home/z/code/d/bloqq/source/arsd/simpleaudio.d:2929: undefined reference to `snd_strerror'
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1
/home/z/things/compilers/ldc2/bin/ldc2 failed with exit code 1.

is there some setup or shared library or something I'm missing?

adamdruppe commented 1 year ago

Looks like you didn't add the -lasound library (which the file does automatically when built with a good build system, but dub ignores it... so you have to repeat yourself and add "libs":["asound"] to the config file).

TheZipCreator commented 1 year ago

yep that worked. still kind of annoying that I need to put simpleaudio into my actual project instead of just adding it as a dependency, but hey what can you do. at least it works now.

adamdruppe commented 1 year ago

hopefully they'll have the compiler bug fixed soon. i might also be able to work around it in the source with some hack... just pushed something that includes it.

just i have a lot of big changes pending and don't want to tag. i just accidentally committed 200 more lines than i meant to there but fixing it is too much of a hassle

commit history is a lot of work lol

adamdruppe commented 1 year ago

there slightly more broekn up commit b4ada541d364ba5eb6d76e4634c18267527902bd

but arsd master is now containing breaking changes