I’m trying to write (as my first ever project) a wav media player in pure C.
I downloaded the library, but i can’t get the example code work.
Im on linux, no IDE.
The code
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include </home/name/giraffe/fmodstudioapi20218linux/api/core/inc/fmod.h> // This is the absolute path to the downloaded and extracted library
FSOUND_SAMPLE* handle;
int main()
{
// init FMOD sound system
FSOUND_Init (44100, 32, 0);
// load and play mp3
handle=FSOUND_Sample_Load (0,"./giraffe/kalasnikow.wav",0, 0, 0);
FSOUND_PlaySound (0,handle);
// clean up
FSOUND_Sample_Free (handle);
FSOUND_Close();
}
I tried to compile it with this line:
gcc random.c -L/home/i3hunor/giraffe/fmodstudioapi20218linux/api/core/inc/ -l/home/i3hunor/giraffe/fmodstudioapi20218linux/bin/lib -o random
The error message:
random.c:6:5: error: unknown type name ‘FSOUND_SAMPLE’
6 | FSOUND_SAMPLE* handle;
| ^~~~~~~~~~~~~
random.c: In function ‘main’:
random.c:10:8: warning: implicit declaration of function ‘FSOUND_Init’ [-Wimplicit-function-declaration]
10 | FSOUND_Init (44100, 32, 0);
| ^~~~~~~~~~~
random.c:13:15: warning: implicit declaration of function ‘FSOUND_Sample_Load’ [-Wimplicit-function-declaration]
13 | handle=FSOUND_Sample_Load (0,"./giraffe/kalasnikow.wav",0, 0, 0);
| ^~~~~~~~~~~~~~~~~~
random.c:13:14: warning: assignment to ‘int *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
13 | handle=FSOUND_Sample_Load (0,"./giraffe/kalasnikow.wav",0, 0, 0);
| ^
random.c:14:8: warning: implicit declaration of function ‘FSOUND_PlaySound’ [-Wimplicit-function-declaration]
14 | FSOUND_PlaySound (0,handle);
| ^~~~~~~~~~~~~~~~
random.c:17:8: warning: implicit declaration of function ‘FSOUND_Sample_Free’ [-Wimplicit-function-declaration]
17 | FSOUND_Sample_Free (handle);
| ^~~~~~~~~~~~~~~~~~
random.c:18:8: warning: implicit declaration of function ‘FSOUND_Close’ [-Wimplicit-function-declaration]
18 | FSOUND_Close();
| ^~~~~~~~~~~~
I have no idea what to do and i don’t know if the #include
part or the gcc
part is responsible for the errors.
Any idea what can i do? I have never used any library other than standard c librarys.