A set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO, and WASAPI) operating systems.
Other
1.49k
stars
317
forks
source link
Undefined Reference to pthread_mutex_* in MinGW since 6.0.0 #407
Compiling in Windows 10 with MinGW 13.1.0 leads to an undefined reference to `pthreadmutex*' functions. I checked out the 5.2.0 tag and the project compiles fine. I found a solution described at the end.
Output of cmake .. -G "MinGW Makefiles"
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: C:/pkg-config-lite-0.28-1/bin/pkg-config.exe (found version "0.28")
-- Checking for module 'jack'
-- No package 'jack' found
-- No package 'libpulse-simple' found
-- Looking for gettimeofday
-- Looking for gettimeofday - found
-- Compiling with support for: wasapi
-- Configuring done (2.6s)
-- Generating done (0.5s)
-- Build files have been written to: C:/rtaudio/build
Output of cmake --build .
[ 10%] Building CXX object CMakeFiles/rtaudio.dir/rtaudio_c.cpp.obj
[ 15%] Linking CXX shared library librtaudio.dll
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x8da): undefined reference to `pthread_mutex_init'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x9a6): undefined reference to `pthread_mutex_destroy'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x168e): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x16af): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x16cd): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x173e): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x31bc): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3207): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x322c): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3255): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x34df): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3504): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3589): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3628): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3687): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x36b0): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3735): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x37db): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x380f): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3838): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x38bd): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3963): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3997): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x39d5): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3b3a): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3c0b): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3da7): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x3e08): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x43af): undefined reference to `pthread_mutex_unlock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x43d8): undefined reference to `pthread_mutex_lock'
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\rtaudio.dir/objects.a(RtAudio.cpp.obj):RtAudio.cpp:(.text+0x4412): undefined reference to `pthread_mutex_unlock'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [CMakeFiles\rtaudio.dir\build.make:116: librtaudio.dll] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:142: CMakeFiles/rtaudio.dir/all] Error 2
mingw32-make: *** [Makefile:145: all] Error 2
Solution
The project compiles fine when I add pthread to target_link_libraries, but this is obviously not a good solution, i.e.,
Compiling in Windows 10 with MinGW 13.1.0 leads to an undefined reference to `pthreadmutex*' functions. I checked out the 5.2.0 tag and the project compiles fine. I found a solution described at the end.
Output of
cmake .. -G "MinGW Makefiles"
Output of
cmake --build .
Solution
The project compiles fine when I add
pthread
totarget_link_libraries
, but this is obviously not a good solution, i.e.,