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

Fix the problem of mingw compilation under msys2 #295

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Huiyicc
Copy link

@Huiyicc Huiyicc commented May 6, 2024

In the msys2 Mingw64 environment, I attempted to compile with the following command directly:

cmake -DCMAKE_INSTALL_PREFIX=$(pwd)/../../  -DCMAKE_BUILD_TYPE=Release $(pwd)/../../libsoundio

output:

.....[details omitted for brevity]

Installation Summary
--------------------
* Install Directory            : /F/Engcode/AIAssistant/audio_client/lib
* Build Type                   : Release
* Build static libs            : ON
* Build examples               : OFF
* Build tests                  : OFF

System Dependencies
-------------------
* threads                      : OK
* JACK       (optional)        : not found
* PulseAudio (optional)        : not found
* ALSA       (optional)        : not found
* CoreAudio  (optional)        : not found
* WASAPI     (optional)        : not found

-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /F/Engcode/AIAssistant/audio_client/lib/build/libsoundio

make &&make install

error:

[  7%] Building C object CMakeFiles/libsoundio_shared.dir/src/soundio.c.o
......[details omitted for brevity]
[100%] Linking C static library libsoundio.a
D:/SDK/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libsoundio_shared.dir/src/os.c.o:os.c:(.text+0x11): undefined reference to `__imp_CoInitializeEx'
D:/SDK/MSYS2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/libsoundio_shared.dir/src/os.c.o:os.c:(.text+0x1e): undefined reference to `__imp_CoUninitialize'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/libsoundio_shared.dir/build.make:177: msys-soundio-2.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/libsoundio_shared.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[100%] Built target libsoundio_static
make: *** [Makefile:136: all] Error 2

After meticulously verifying the msys environment versus the Windows environment within CMake

# make -j12&& make install
[  2%] Building C object CMakeFiles/libsoundio_shared.dir/src/soundio.c.o
[ 11%] Building C object CMakeFiles/libsoundio_static.dir/src/util.c.o
......
[ 65%] Linking C executable latency.exe
[ 68%] Linking C executable unit_tests.exe
[ 68%] Built target libsoundio_shared
[ 68%] Built target unit_tests
[ 68%] Built target latency
[ 70%] Building C object CMakeFiles/sio_sine.dir/example/sio_sine.c.o
[ 72%] Building C object CMakeFiles/sio_list_devices.dir/example/sio_list_devices.c.o
[ 84%] Building C object CMakeFiles/overflow.dir/test/overflow.c.o
[ 84%] Building C object CMakeFiles/sio_record.dir/example/sio_record.c.o
[ 84%] Building C object CMakeFiles/sio_microphone.dir/example/sio_microphone.c.o
[ 84%] Building C object CMakeFiles/underflow.dir/test/underflow.c.o
[ 84%] Building C object CMakeFiles/backend_disconnect_recover.dir/test/backend_disconnect_recover.c.o
[ 84%] Built target libsoundio_static
[ 86%] Linking C executable sio_sine.exe
[ 88%] Linking C executable sio_list_devices.exe
[ 90%] Linking C executable backend_disconnect_recover.exe
[ 93%] Linking C executable overflow.exe
[ 97%] Linking C executable underflow.exe
[ 97%] Linking C executable sio_record.exe
[100%] Linking C executable sio_microphone.exe
[100%] Built target sio_sine
[100%] Built target sio_list_devices
[100%] Built target backend_disconnect_recover
[100%] Built target sio_record
[100%] Built target underflow
[100%] Built target overflow
[100%] Built target sio_microphone
[ 15%] Built target libsoundio_shared
[ 31%] Built target libsoundio_static
[ 36%] Built target sio_sine
[ 40%] Built target sio_list_devices
[ 45%] Built target sio_microphone
[ 50%] Built target sio_record
[ 68%] Built target unit_tests
[ 86%] Built target latency
[ 90%] Built target underflow
[ 95%] Built target backend_disconnect_recover
[100%] Built target overflow
Install the project...
-- Install configuration: "Release"
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/lib/libsoundio.dll.a
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/lib/msys-soundio-2.dll
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/lib/libsoundio.a
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/include/soundio/soundio.h
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/include/soundio/endian.h
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/bin/sio_sine.exe
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/bin/sio_list_devices.exe
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/bin/sio_microphone.exe
-- Installing: /F/Engcode/AIAssistant/audio_client/lib/bin/sio_record.exe

perfect~

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 this pull request may close these issues.

1 participant