C++ FMOD Install
This guide will provide step-by-step instructions on how to add the FMOD library to a Visual Studio C++ project. You will learn how to download and set up FMOD, configure Visual Studio to recognize the library, and integrate FMOD into your project for enhanced multimedia capabilities. By the end of this guide, you will be ready to utilize FMOD in your Visual Studio C++ projects.
About FMOD
FMOD is a proprietary sound effects engine and authoring tool for video games and applications. It is able to play and mix sounds of diverse formats on many operating systems. FMOD is used many popular game engines like Unity and Unreal Engine.
Download FMOD
- Go to the FMOD website https://www.fmod.com/
- Go to the Sign In and sign up for an account if you don’t have one
- Go to the Download
- Download the FMOD Engine for Windows
- Install the downloaded FMOD Engine file (accepts all defaults)
- Create a folder in the Solution directory called “ThirdParty”, if one doesn’t exist
- ThirdParty will contain libraries from external developers to be used in the project
- Create a folder in the ThirdParty folder called “fmod”
- Navigate to where FMOD was installed on your computer
- The default location (copy into Windows Explorer):
1
C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows
- In the api folder, copy the core folder into the ThirdParty\fmod folder
Add FMOD to the Solution Project(s)
Add FMOD Include Directories
- Add the directory of the FMOD include folder to the Additional Include Directories.
- Additional Include Directories is located in C/C++>General.
- Add
$(SolutionDir)ThirdParty\fmod\core\inc
1
$(SolutionDir)ThirdParty\fmod\core\inc
This needs to be done in all Projects in the Solution.
- Once the directory is added to the list of included directories, the FMOD header can be add to the files.
- Add the following to a file
1
#include <fmod.hpp>
- Add the following to a file
If the FMOD include directory was properly added, building the project (CTRL+B) will result in no errors.
Add FMOD Library Directories and Library (.lib)
If the Solution contains multiple Projects, the following steps will need to be done for each project. This is because each project needs the path to the FMOD includes and libraries.
In the Project Properties, make sure that the Configuration is set to All Configurations and Platform is set to All Platforms.
- Add the directory of the FMOD library folder in Project Properties
- Additional Library Directories is located in Librarian>General or Linker>Input
- Add
$(SolutionDir)ThirdParty\fmod\core\lib\$(PlatformTarget)
1
$(SolutionDir)ThirdParty\fmod\core\lib\$(PlatformTarget)
The fmod_vc.lib only needs to be added on the project that is the application (Game). Do not add it to the library project (Engine). If it is added to both, there will be a warning reported when built.
- Add the FMOD .lib files that the project needs to function
- Additional Dependencies is located in Librarian>General or Linker>General
- Add
fmod_vc.lib
1
fmod_vc.lib
If the FMOD library was properly added, building the project (CTRL+B) will result in no errors.
Add SDL Dynamic Link Library (dll)
- Create a folder in the Solution directory called “Build”
- This step might have already been done previously
- The Build folder will contain the FMOD dll (dynamic link library) files.
- Copy the fmod.dll file from the ThirdParty\fmod\core\lib\x64 directory to the Build folder.
- The project is a x64 project (64-bit application).
The next step might have already been completed in a previous guide.
- Set the Working Directory that the project will be run from in Project Properties
- Working Directory is located in Debugging
- Add
$(SolutionDir)Build
1
$(SolutionDir)Build
If FMOD was properly added, building and running the project will result in no errors.
Create FMOD System
- A sound (.wav) file will need to be added to the Build folder to work. For this example a sound file “test.wav” was added. Any available sound file can be used.
You can download this file if needed: test.wav
- In main() add the following code to create the audio system (place where the engine systems are created):
1 2 3 4 5 6
// create audio system FMOD::System* audio; FMOD::System_Create(&audio); void* extradriverdata = nullptr; audio->init(32, FMOD_INIT_NORMAL, extradriverdata);
- In main() add the following code to load and play a sound (place before the main loop):
1 2 3 4
FMOD::Sound* sound = nullptr; audio->createSound("test.wav", FMOD_DEFAULT, 0, &sound); audio->playSound(sound, 0, false, nullptr);
- In main() inside the main loop add the following to update FMOD:
1
audio->update();
Build and run the Solution and the “test.wav” will be played at startup.