kcat / openal-soft

OpenAL Soft is a software implementation of the OpenAL 3D audio API.
Other
2.23k stars 536 forks source link

Build failure when compiling as a CMake subdirectory with MinGW. #990

Closed Domssson closed 7 months ago

Domssson commented 7 months ago

If the library code is added as a subdirectory in a CMake project and then cross-compiled with MinGW on Linux, the build fails. During linking, the OpenAL32.def file is created just inside the build directory, but then it's expected to be in build/openal-soft by sed command. If one copies the OpenAL32.def file to the correct directory and runs cmake --build . again, the build process proceeds as it should.

Here's a very simple CMake script that triggers this behaviour, assuming that the library is in the openal-soft directory in the project:

cmake_minimum_required(VERSION 3.12)

project(TestProject)

add_subdirectory(openal-soft)

The solution to the problem would be to generate the OpenAL32.def in the correct directory when linking.

Here is the log from CMake:

[1/1] Linking CXX shared library openal-soft/OpenAL32.dll
FAILED: openal-soft/OpenAL32.dll openal-soft/libOpenAL32.dll.a openal-soft/OpenAL32.def openal-soft/OpenAL32.lib /home/dominik/Pobrane/Biblioteki programistyczne/OpenAL-BugTest/build/openal-soft/OpenAL32.def /home/dominik/Pobrane/Biblioteki programistyczne/OpenAL-BugTest/build/openal-soft/OpenAL32.lib 
: && /usr/bin/x86_64-w64-mingw32-g++ -O2 -g -D_DEBUG  -Wl,--output-def,OpenAL32.def -shared -o openal-soft/OpenAL32.dll -Wl,--out-implib,openal-soft/libOpenAL32.dll.a -Wl,--major-image-version,1,--minor-image-version,23 openal-soft/CMakeFiles/OpenAL.dir/al/auxeffectslot.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/buffer.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/debug.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effect.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/autowah.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/chorus.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/compressor.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/convolution.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/dedicated.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/distortion.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/echo.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/effects.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/equalizer.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/fshifter.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/modulator.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/null.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/pshifter.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/reverb.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/effects/vmorpher.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/error.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/event.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/extension.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/filter.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/listener.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/source.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/state.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/eax/api.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/eax/call.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/eax/exception.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/eax/fx_slot_index.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/eax/fx_slots.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/al/eax/utils.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/alc.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/alu.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/alconfig.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/context.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/device.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/autowah.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/chorus.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/compressor.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/convolution.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/dedicated.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/distortion.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/echo.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/equalizer.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/fshifter.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/modulator.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/null.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/pshifter.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/reverb.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/effects/vmorpher.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/events.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/panning.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/backends/base.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/backends/loopback.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/backends/null.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/backends/winmm.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/backends/dsound.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/backends/wasapi.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/alc/backends/wave.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/ambdec.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/ambidefs.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/bformatdec.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/bs2b.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/bsinc_tables.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/buffer_storage.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/context.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/converter.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/cpu_caps.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/cubic_tables.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/devformat.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/device.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/effectslot.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/except.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/filters/biquad.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/filters/nfc.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/filters/splitter.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/fmt_traits.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/fpu_ctrl.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/helpers.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/hrtf.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/logging.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/mastering.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/mixer.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/storage_formats.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/uhjfilter.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/uiddefs.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/voice.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/mixer/mixer_c.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/mixer/mixer_sse.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/mixer/mixer_sse2.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/mixer/mixer_sse3.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/core/mixer/mixer_sse41.cpp.obj openal-soft/CMakeFiles/OpenAL.dir/resources/openal32.rc.res  openal-soft/libalcommon.a  -lwinmm  -latomic  -lm  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd "/home/dominik/Pobrane/Biblioteki programistyczne/OpenAL-BugTest/build/openal-soft" && /usr/bin/sed -i -e "s/ @[^ ]*//" OpenAL32.def && /usr/bin/x86_64-w64-mingw32-dlltool -d OpenAL32.def -l OpenAL32.lib -D OpenAL32.dll
/usr/bin/sed: could not read OpenAL32.def: No such file or directory
ninja: build stopped: subcommand failed.

Here is the minimal project: MinimalProject.zip

Domssson commented 7 months ago

The issue was resolved in a pull request.