Title
Fix Linux Linker Error: Undefined reference to dlclose in miniaudio_impl
Description
Hi Sarah! First of all, thank you for your amazing work on InmarScope. I successfully compiled and ran the application natively on Linux (Xubuntu 20.04), but the compilation fails at the very last step ([346/346]) due to a missing linker flag for Linux's dynamic loading library.
Since miniaudio requires dynamic loading to interface with Linux audio drivers, GCC/Clang needs an explicit -ldl flag passed during the linking stage. On Windows/MSYS2, this functionality is implicit, which is why it works perfectly there but breaks on Linux.
Exact Linker Error Log
[346/346] Linking CXX executable InmarScope
FAILED: InmarScope
... -o InmarScope ... -lpthread && :
/usr/bin/ld: CMakeFiles/InmarScope.dir/src/audio/miniaudio_impl.cpp.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The Solution (Permanent CMake Fix)
To permanently fix this for all Linux users without impacting Windows builds, the following platform check can be appended to the bottom of the main CMakeLists.txt file (or wherever the InmarScope target linking is defined):
if(UNIX AND NOT APPLE)
target_link_libraries(InmarScope dl)endif()
This guarantees that -ldl is appended properly at the end of the compiler's link command on Linux systems. Thank you again for keeping this project moving forward, looking forward to the upcoming RSP input source support!
Title
Fix Linux Linker Error: Undefined reference to dlclose in miniaudio_impl
Description
Hi Sarah! First of all, thank you for your amazing work on InmarScope. I successfully compiled and ran the application natively on Linux (Xubuntu 20.04), but the compilation fails at the very last step ([346/346]) due to a missing linker flag for Linux's dynamic loading library.
Since miniaudio requires dynamic loading to interface with Linux audio drivers, GCC/Clang needs an explicit -ldl flag passed during the linking stage. On Windows/MSYS2, this functionality is implicit, which is why it works perfectly there but breaks on Linux.
Exact Linker Error Log
[346/346] Linking CXX executable InmarScope
FAILED: InmarScope
... -o InmarScope ... -lpthread && :
/usr/bin/ld: CMakeFiles/InmarScope.dir/src/audio/miniaudio_impl.cpp.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
The Solution (Permanent CMake Fix)
To permanently fix this for all Linux users without impacting Windows builds, the following platform check can be appended to the bottom of the main CMakeLists.txt file (or wherever the InmarScope target linking is defined):
if(UNIX AND NOT APPLE)
target_link_libraries(InmarScope dl)endif()
This guarantees that -ldl is appended properly at the end of the compiler's link command on Linux systems. Thank you again for keeping this project moving forward, looking forward to the upcoming RSP input source support!