# How to include fmod library to C?

**URL:** <https://qa.fmod.com/t/how-to-include-fmod-library-to-c/20775>\
**Category:** FMOD Engine\
**Created:** [October 16, 2023, 2:07pm UTC](https://qa.fmod.com/t/how-to-include-fmod-library-to-c/20775 "2023-10-16T14:07:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![I15](https://avatars.discourse-cdn.com/v4/letter/i/9de053/32.png) [@I15](https://qa.fmod.com/u/I15)\
**Post date:** [October 16, 2023, 2:07pm UTC](https://qa.fmod.com/t/how-to-include-fmod-library-to-c/20775/1 "2023-10-16T14:07:55Z")

</div>

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**

```c
#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:**

```c
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.

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [October 17, 2023, 5:20am UTC](https://qa.fmod.com/t/how-to-include-fmod-library-to-c/20775/2 "2023-10-17T05:20:30Z")

</div>

Hi,

As far as I can tell, the issue isn’t that you haven’t included the FMOD library, but that you’re using extremely outdated API functions. All of the `FSOUND`-related objects and functions no longer exist.

I would recommend taking a look at the examples included with the FMOD Engine Linux installer at `./api/core/examples`, specifically the “play\_sound” example, which provides a simple example of playing a few sounds. I would also recommend taking a look at our [Core API Reference](https://www.fmod.com/docs/2.02/api/core-api.html) to familiarize yourself with the API functions as they are currently.
