# How to set up FMOD Engine with Qt6 MinGW 64-bit

**URL:** <https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384>\
**Category:** FMOD Engine\
**Tags:** cpp\
**Created:** [March 19, 2024, 6:11pm UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384 "2024-03-19T18:11:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![8Observer8](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/8observer8/32/5439_2.png) [@8Observer8](https://qa.fmod.com/u/8Observer8)\
**Post date:** [March 19, 2024, 6:11pm UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/1 "2024-03-19T18:11:06Z")

</div>

I want to try to run FMOD on Windows 10 with Qt6 MinGW 64-bit but I have a problem: `undefined reference to `FMOD_System_Create'`. My steps are below.

I downloaded “FMOD Engine”:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/f/f3753a35624ea2b427461ccb29b8e0f57bc6b797.png)

This is the contains of the “lib/x64” folder:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/5559af9b5a4b8f1792b6269b5a5d45861122c5e4.png)

There are no the `fmod.a` file here. I tried to include “fmod.dll” like this:

```auto
INCLUDEPATH += "E:/Libs/fmod-2.2.21-mingw-64-bit/include"
LIBS += -L"E:/Libs/fmod-2.2.21-mingw-64-bit/lib/x64/fmod.dll"

```

But I have this error: `undefined reference to `FMOD_System_Create'`

I tried to use FMOD with SFML in makefile. It works without the problem:

```auto
CC = g++
INC = -I"E:\Libs\SFML-2.5.1-windows-gcc-7.3.0-mingw-64-bit\include" \
      -I"E:\Libs\box2d-2.4.1-mingw-64-bit\include" \
      -I"E:\Libs\fmod-2.2.21-mingw-64-bit\include"
LIB = -L"E:\Libs\SFML-2.5.1-windows-gcc-7.3.0-mingw-64-bit\lib" \
      -L"E:\Libs\box2d-2.4.1-mingw-64-bit\lib"
FLAGS = -c -DSFML_STATIC
 
all: main.o
    $(CC) main.o $(LIB) -static \
    "E:\Libs\fmod-2.2.21-mingw-64-bit\lib\x64\fmod.dll" \
    -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lfreetype \
    -lopengl32 -lwinmm -lgdi32 -lbox2d -o app
 
main.o: main.cpp
    $(CC) $(FLAGS) $(INC) main.cpp

```

---

<div class="post-metadata">

**Author:** ![Andrew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/andrew/32/261_2.png) [@Andrew](https://qa.fmod.com/u/Andrew)\
**Post date:** [March 20, 2024, 12:03am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/2 "2024-03-20T00:03:06Z")

</div>

Looks like you need to add the library path like so: -L"E:\Libs\fmod-2.2.21-mingw-64-bit\lib\x64"  
And instead of specifying the full path to fmod.dll on your command line (“E:\Libs\fmod-2.2.21-mingw-64-bit\lib\x64\fmod.dll”) you should use -lfmod instead.

---

<div class="post-metadata">

**Author:** ![8Observer8](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/8observer8/32/5439_2.png) [@8Observer8](https://qa.fmod.com/u/8Observer8)\
**Post date:** [March 20, 2024, 8:15am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/3 "2024-03-20T08:15:05Z")

</div>

Thank you very much! I didn’t know that I can use `LIBS += -lfmod` with DLLs. I thought I can use it with `.a` only. The absolution paths work with the problem:

```auto
INCLUDEPATH += "E:/libs/fmod-2.2.21-mingw-64-bit/include"
LIBS += -L"E:/libs/fmod-2.2.21-mingw-64-bit/lib/x64/"
LIBS += -lfmod

```

But when I copy the `fmod-2.2.21-mingw-64-bit` folder to my project in the `libs` folder and try to set up it with a relative path:

```auto
INCLUDEPATH += $$PWD/libs/fmod-2.2.21-mingw-64-bit/include
LIBS += $$PWD/libs/fmod-2.2.21-mingw-64-bit/lib/x64
LIBS += -lfmod

```

I see this error:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/2fdd59a6d3ef5f9b2a803c13004cdd2a9faebd3e.png)

It can be solved by copying `fmod.dll` to the Debug folder:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/c/c3ad6de3495fc037a499df02623b582f54bfdb2e.png)

Is it possible do not copy it manually? This is very bad that you don’t have `libfmod.a` for x64:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/d32412e31b2cd1363329da392f77db6964c30aba.png)

There is `libfmod.a` for x86:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/2ec0768336d8ad37efcba70818d2eb2fcfdcf9bb.png)

---

<div class="post-metadata">

**Author:** ![8Observer8](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/8observer8/32/5439_2.png) [@8Observer8](https://qa.fmod.com/u/8Observer8)\
**Post date:** [March 20, 2024, 9:10am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/5 "2024-03-20T09:10:03Z")

</div>

It seams like I cannot use the relative set up path without manual copying of `fmod.dll` to the Debug folder:

```auto
INCLUDEPATH += $$PWD/libs/fmod-2.2.21-mingw-64-bit/include
LIBS += $$PWD/libs/fmod-2.2.21-mingw-64-bit/lib/x64
LIBS += -lfmod

```

But why I don’t need to copy `fmod.dll` to the Debug folder when I set up FMOD using the absolute set up path:

```auto
INCLUDEPATH += "E:/libs/fmod-2.2.21-mingw-64-bit/include"
LIBS += -L"E:/libs/fmod-2.2.21-mingw-64-bit/lib/x64/"
LIBS += -lfmod

```

---

<div class="post-metadata">

**Author:** ![8Observer8](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/8observer8/32/5439_2.png) [@8Observer8](https://qa.fmod.com/u/8Observer8)\
**Post date:** [March 20, 2024, 10:00am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/6 "2024-03-20T10:00:10Z")

</div>

This is my simple project for Qt6 MinGW 64-bit that plays the OGG audio file on Windows: [play-audio-from-resources-fmod-qt6-cpp.zip](https://www.dropbox.com/scl/fi/u0r4wzu8ayohar5a2qb8q/play-audio-from-resources-fmod-qt6-cpp.zip?rlkey=ww1klngzgytkifgx9s9xyl1c3&dl=1) (2.77 MB) You can download it and experiment with the relative set up file. There is the `libs` folder with FMOD 2.2.21 inside of the project folder. I want to run it without manual copying of `fmod.dll` to the Debug folder. You can create the `libs` folder on your hard drive and copy my contains of ‘libs’ folder to it to check that absolute set up path doesn’t require manual copying of `fmod.dll` to the Debug folder. You should to uncomment the absolute set up path and comment the relative path (don’t forget to change a name of hard drive):

play-audio-from-resources-fmod-qt6-cpp.pro:

```auto
QT += core gui widgets

CONFIG += c++17

# The absolute set up FMOD path
# Works without manual copying of fmod.dll to the Debug folder
# INCLUDEPATH += "E:/libs/fmod-2.2.21-mingw-64-bit/include"
# LIBS += -L"E:/libs/fmod-2.2.21-mingw-64-bit/lib/x64/"
# LIBS += -lfmod

# The relative set up FMOD path
# Requires manual copying of fmod.dll to the Debug folder
INCLUDEPATH += $$PWD/libs/fmod-2.2.21-mingw-64-bit/include
LIBS += $$PWD/libs/fmod-2.2.21-mingw-64-bit/lib/x64
LIBS += -lfmod

# Using fmod_vc.lib
# Requires manual copying of fmod.dll to the Debug folder
# INCLUDEPATH += $$PWD/libs/fmod-2.2.21-mingw-64-bit/include
# LIBS += $$PWD/libs/fmod-2.2.21-mingw-64-bit/lib/x64/fmod_vc.lib

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# Disables all the APIs deprecated before Qt 6.0.0
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000

SOURCES += \
    main.cpp \
    widget.cpp

HEADERS += \
    widget.h

RESOURCES += \
    assets.qrc

```

widget.h

```cpp
#ifndef WIDGET_H
#define WIDGET_H

#include <QtWidgets/QWidget>
#include <fmod.h>

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private:
    FMOD_SYSTEM *m_system;
    FMOD_SOUND *m_sound;
};

#endif // WIDGET_H

```

widget.cpp

```cpp
#include "widget.h"

#include <QtCore/QByteArray>
#include <QtCore/QFile>
#include <QtCore/QString>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    FMOD_System_Create(&m_system, FMOD_VERSION);
    FMOD_System_Init(m_system, 32, FMOD_INIT_NORMAL, 0);

    QString soundPath(":/assets/audio/overworld.ogg");
    QFile f(soundPath);
    if (!f.open(QIODevice::OpenModeFlag::ReadOnly))
    {
        qDebug() << "Faild to open the file: " << soundPath;
        return;
    }
    QByteArray soundData = f.readAll();
    f.close();

    FMOD_CREATESOUNDEXINFO* exinfo = new FMOD_CREATESOUNDEXINFO();
    exinfo->length = static_cast<unsigned int>(soundData.length());
    exinfo->cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
    FMOD_System_CreateSound(m_system, soundData.data(), FMOD_OPENMEMORY, exinfo, &m_sound);

    FMOD_Sound_SetMode(m_sound, FMOD_LOOP_OFF);

    FMOD_System_PlaySound(m_system, m_sound, 0, false, 0);
}

Widget::~Widget()
{
    delete m_system;
    delete m_sound;
}

```

main.cpp

```cpp
#include "widget.h"

#include <QtWidgets/QApplication>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Widget w;
    w.show();
    return app.exec();
}

```

assets.qrc

```xml
<RCC>
    <qresource prefix="/">
        <file>assets/audio/overworld.ogg</file>
    </qresource>
</RCC>

```

---

<div class="post-metadata">

**Author:** ![8Observer8](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/8observer8/32/5439_2.png) [@8Observer8](https://qa.fmod.com/u/8Observer8)\
**Post date:** [March 20, 2024, 11:22am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/7 "2024-03-20T11:22:29Z")

</div>

So I want to run my app inside of Qt Creator with relative set up path (with using `$$PWD` instead of `"E:/`) because I want to distribute my examples with included libs. For example, I can post my examples (ZIPs) on the forums and people can download it and run without set up of FMOD and so on. And without manual copying of `fmod.dlll` to the Debug folder. For a while the `"E:/` method (absolute path) works without manual copying of `fmod.dll` but the `$$PWD` method (relative path) requires to copy `fmod.dll` to the Debug folder. The distribution of EXE is very clear for me. Yes, of course I should distribute `fmod.dll`, `Qt6Core.dll` and so on with EXE. My question about distribution of Qt project with libs to run it very quickly in Qt Creator on another computer.

The `$$PWD` method (relative path) allows to include all libs to a project. I should works like this - everyone can download the project and run it without downloading requires libs and without manual copying of `fmod.dll` to the Debug folder:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/581de86c556fe780b752a152afbd02576421ddb2.png)

---

<div class="post-metadata">

**Author:** ![Andrew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/andrew/32/261_2.png) [@Andrew](https://qa.fmod.com/u/Andrew)\
**Post date:** [March 21, 2024, 4:11am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/8 "2024-03-21T04:11:07Z")

</div>

It sounds like your problem is solved. On Windows you generally ship fmod.dll in the same directory as your .exe. If your .exe is being built to the “debug” directory then you need to make sure your build process copies fmod.dll there too. Can you copy it there in a build step?

---

<div class="post-metadata">

**Author:** ![8Observer8](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/8observer8/32/5439_2.png) [@8Observer8](https://qa.fmod.com/u/8Observer8)\
**Post date:** [March 21, 2024, 9:07am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/9 "2024-03-21T09:07:24Z")

</div>

It looks like you skipped this text:

> But why I don’t need to copy `fmod.dll` to the Debug folder when I set up FMOD using the absolute set up path:

```auto
INCLUDEPATH += "E:/libs/fmod-2.2.21-mingw-64-bit/include"
LIBS += -L"E:/libs/fmod-2.2.21-mingw-64-bit/lib/x64/"
LIBS += -lfmod

```

I have tested many times that these settings above do NOT require copying `fmod.dll` to the debug directory:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/b/bd642875d17c61206715560c252902dba51ce6f9.png)

Please, download my example [play-audio-from-resources-fmod-qt6-cpp.zip](https://www.dropbox.com/scl/fi/u0r4wzu8ayohar5a2qb8q/play-audio-from-resources-fmod-qt6-cpp.zip?rlkey=ww1klngzgytkifgx9s9xyl1c3&dl=1) to run it in Qt Creator. You will find this folder inside of my example: `libs/fmod-2.2.21-mingw-64-bit`:

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/581de86c556fe780b752a152afbd02576421ddb2.png)

Copy the `libs/fmod-2.2.21-mingw-64-bit` folder to your E disk and uncomment these setting in the pro file:

```auto
INCLUDEPATH += "E:/libs/fmod-2.2.21-mingw-64-bit/include"
LIBS += -L"E:/libs/fmod-2.2.21-mingw-64-bit/lib/x64/"
LIBS += -lfmod

```

Let me know that my example does NOT require to copy `fmod.dll` manually.

My question is about why I cannot use the next settings without manual copying of `fmod.dll` (like I can do with setting above):

```auto
INCLUDEPATH += $$PWD/libs/fmod-2.2.21-mingw-64-bit/include
LIBS += $$PWD/libs/fmod-2.2.21-mingw-64-bit/lib/x64
LIBS += -lfmod

```

---

<div class="post-metadata">

**Author:** ![8Observer8](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/8observer8/32/5439_2.png) [@8Observer8](https://qa.fmod.com/u/8Observer8)\
**Post date:** [March 22, 2024, 3:58pm UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/10 "2024-03-22T15:58:26Z")

</div>

**jsulm** answered [here](https://forum.qt.io/post/793809) that SUBDIRS can help to copy `fmod.dll` during the build. I didn’t try it.

> [@8Observer8](https://forum.qt.io/uid/9354) It looks like the library is part of your project. You could use [SUBDIRS - handling dependencies - Qt Wiki](https://wiki.qt.io/SUBDIRS_-_handling_dependencies) project and make your main project depend on the library sub-project. In that case the libs should be copied during the build.

---

<div class="post-metadata">

**Author:** ![Andrew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/andrew/32/261_2.png) [@Andrew](https://qa.fmod.com/u/Andrew)\
**Post date:** [March 25, 2024, 5:12am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/11 "2024-03-25T05:12:12Z")

</div>

Sorry, but this is not an FMOD-specific issue, it’s an issue with your Qt Creator usage. I think you’ve done the right thing by creating a thread on the Qt forums - the people there will be able to help you with Qt Creator issues better than we can.

---

<div class="post-metadata">

**Author:** ![8Observer8](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/8observer8/32/5439_2.png) [@8Observer8](https://qa.fmod.com/u/8Observer8)\
**Post date:** [March 25, 2024, 11:00am UTC](https://qa.fmod.com/t/how-to-set-up-fmod-engine-with-qt6-mingw-64-bit/21384/12 "2024-03-25T11:00:17Z")

</div>

I solved the problem with the relative paths to the library! I just added `-L` before `$$PWD` like this:

```auto
INCLUDEPATH += $$PWD/libs/fmod-2.2.21-mingw-64-bit/include
LIBS += -L$$PWD/libs/fmod-2.2.21-mingw-64-bit/lib/x64
LIBS += -lfmod

```

Now you can download the next example and run it in Qt Creator (with MinGW 64) without necessary to set up FMOD or changing the paths in pro-file: [play-audio-from-resources-fmod-qt6-cpp.zip](https://www.dropbox.com/scl/fi/gusrz05sionkldsw0ydom/play-audio-from-resources-fmod-qt6-cpp.zip?rlkey=7wdkgglqzcxmojzbb3udlp962&dl=1) (2.51 MB)
