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.
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:
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 (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:
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
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:
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?
I have tested many times that these settings above do NOT require copying fmod.dll to the debug directory:
Please, download my example play-audio-from-resources-fmod-qt6-cpp.zip to run it in Qt Creator. You will find this folder inside of my example: libs/fmod-2.2.21-mingw-64-bit:
Copy the libs/fmod-2.2.21-mingw-64-bit folder to your E disk and uncomment these setting in the pro file:
jsulm answered here that SUBDIRS can help to copy fmod.dll during the build. I didn’t try it.
@8Observer8 It looks like the library is part of your project. You could use SUBDIRS - handling dependencies - Qt Wiki project and make your main project depend on the library sub-project. In that case the libs should be copied during the build.
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.
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 (2.51 MB)