I want to play audio files in OpenGL in Cygwin environment

Asked 2 years ago, Updated 2 years ago, 446 views

I am working on the game with opengl, but the following error occurred and I cannot execute it.
Can't I use PlaySound because it's a Windows-specific function?Also, please let me know if there is any other way to play the wav file on opengl.

/cygdrive/c/Users/nimon/AppData/Local/Temp/cch6fo9W.o:shadowHunter.c: (.text+0x1080): Undefined reference to `_imp__PlaySoundA@12'
collect2:Error: ld terminated with status 1
make:*** [Makefile:31:ShadowHunter.exe] Error 1

The source code for the program you ran is as follows.

#include<stdio.h>
# include <Windows.h>
# pragma comment (lib, "winmm.lib")
int main() {
PlaySound(TEXT("sample.wav"), NULL, SND_FILENAME | SND_LOOP | SND_ASYNC);
return 0;
}

opengl cygwin

2022-10-06 01:00

1 Answers

#pragma comment(lib, "winmm.lib")

This statement is Microsoft Visual C++ proprietary and cannot be used in any other environment.If you are developing while browsing through documents in Windows, it is recommended that you use Visual C++, the standard compiler.Cygwin is less confusing after you understand the standard compiler.

In addition, gcc will probably specify -lwinmm.

Please let me know if there is any way to play the wav file in opengl.

OpenGL is a graphics library and should not be able to handle audio.


2022-10-06 01:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.