Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. How to set up the FMOD audio library in Qt Creator for Android

How to set up the FMOD audio library in Qt Creator for Android

Scheduled Pinned Locked Moved Unsolved Game Development
44 Posts 5 Posters 7.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 8 8Observer8
    18 Aug 2023, 19:17

    @JoeCFD said in How to set up the FMOD audio library in Qt Creator for Android:

    my app supports Android 11, 12 and 13.

    I think Android is backward compatible. That is, if I created applications with the selected Android 4, this means that the application will work not only on Android 4, but also on Android 5, 12 and 13.

    J Offline
    J Offline
    JoeCFD
    wrote on 18 Aug 2023, 20:05 last edited by
    #22

    @8Observer8 I guess not. I built my app for Android 11 and 12 at first. And it did not work on Android 13. I had to add 13 support in the build.

    8 2 Replies Last reply 18 Aug 2023, 20:46
    0
    • J JoeCFD
      18 Aug 2023, 20:05

      @8Observer8 I guess not. I built my app for Android 11 and 12 at first. And it did not work on Android 13. I had to add 13 support in the build.

      8 Offline
      8 Offline
      8Observer8
      wrote on 18 Aug 2023, 20:46 last edited by 8Observer8
      #23

      @JoeCFD I need to check it out. Later, I'm going to create a blank window for Qt for Android 7 and run it on Android 12. I can't believe the blank window won't work.

      1 Reply Last reply
      0
      • J JoeCFD
        18 Aug 2023, 20:05

        @8Observer8 I guess not. I built my app for Android 11 and 12 at first. And it did not work on Android 13. I had to add 13 support in the build.

        8 Offline
        8 Offline
        8Observer8
        wrote on 18 Aug 2023, 20:56 last edited by
        #24

        @JoeCFD My only guess is that an app built for Android 11 doesn't work on Android 13 because it uses APIs that were removed in Android 13, but unless you're using backwards compatibility hacks, then early apps should work on more number of new devices. But this is only my assumption, which I myself have to verify by experience.

        1 Reply Last reply
        0
        • 8 Offline
          8 Offline
          8Observer8
          wrote on 30 Aug 2023, 15:48 last edited by 8Observer8
          #25

          I currently have an Android 13 smartphone. I tried to run my music application using OpenAL. It works on smartphones with Android 13 and 7. This is very good, because I thought that I would have to make a separate build in the APK for each version of the smartphone, starting from Android 7 to13.

          J 1 Reply Last reply 30 Aug 2023, 15:54
          0
          • 8 8Observer8
            30 Aug 2023, 15:48

            I currently have an Android 13 smartphone. I tried to run my music application using OpenAL. It works on smartphones with Android 13 and 7. This is very good, because I thought that I would have to make a separate build in the APK for each version of the smartphone, starting from Android 7 to13.

            J Offline
            J Offline
            JoeCFD
            wrote on 30 Aug 2023, 15:54 last edited by JoeCFD
            #26

            @8Observer8 What I did is to add all SDKs of Android 11, 12 and 13 to the project, but I made only one build . My app works fine in 11, 12 and 13.

            8 1 Reply Last reply 30 Aug 2023, 17:44
            0
            • J JoeCFD
              30 Aug 2023, 15:54

              @8Observer8 What I did is to add all SDKs of Android 11, 12 and 13 to the project, but I made only one build . My app works fine in 11, 12 and 13.

              8 Offline
              8 Offline
              8Observer8
              wrote on 30 Aug 2023, 17:44 last edited by 8Observer8
              #27

              @JoeCFD said in How to set up the FMOD audio library in Qt Creator for Android:

              What I did is to add all SDKs of Android 11, 12 and 13 to the project

              Last time you wrote that if the application is built for Android 7 and Android 12 SDK, then it will not work on Android 13. Interestingly, I was unable to remove the Android 12 SDK from Qt Creator. Qt Creator says that Android 12 SDK is required:

              dc7a508d-767d-4212-bc93-f8b590a6e820-image.png

              I don't have the Android 13 SDK installed, but my app works fine on Android 13 and Android 7:

              ed42d8a1-9f57-445e-8812-eecbb2d5f239-image.png

              23a832d2-107b-4e5f-99bb-b516a4452efe-image.png

              15864b21-df2d-46d2-902c-2ca336c454fc-image.png

              f212cb91-a6f1-481e-b8c2-dcec0cd849cd-image.png

              J 1 Reply Last reply 30 Aug 2023, 23:42
              0
              • 8 Offline
                8 Offline
                8Observer8
                wrote on 30 Aug 2023, 18:05 last edited by
                #28

                My APK file that I asked to try running on Android 13 two weeks ago turned out to work on Android 7 and Android 13. I compiled OpenAL to work with audio for Android 10 (When building OpenAL, I used Android API 29, which is compatible with Android 10). The compiled library works on Android 7 and Android 13. I tested it on real devices. I have the Android 7 and Android 12 SDKs installed in Qt Creator in the SDK manager. Tried to run on Android 7 and Android: OpenAL, Box2D, Bullet Physics and OpenGL ES 2.0. That's all you need to develop 2D and 3D games. Now I'm not interested in wasting time on FMOD. You can read posts from one of the FMOD developers on the official FMOD forum: https://qa.fmod.com/t/qt-application-with-fmod-audio-library-crashes-on-launch-on-android/20561

                1 Reply Last reply
                0
                • 8 8Observer8
                  30 Aug 2023, 17:44

                  @JoeCFD said in How to set up the FMOD audio library in Qt Creator for Android:

                  What I did is to add all SDKs of Android 11, 12 and 13 to the project

                  Last time you wrote that if the application is built for Android 7 and Android 12 SDK, then it will not work on Android 13. Interestingly, I was unable to remove the Android 12 SDK from Qt Creator. Qt Creator says that Android 12 SDK is required:

                  dc7a508d-767d-4212-bc93-f8b590a6e820-image.png

                  I don't have the Android 13 SDK installed, but my app works fine on Android 13 and Android 7:

                  ed42d8a1-9f57-445e-8812-eecbb2d5f239-image.png

                  23a832d2-107b-4e5f-99bb-b516a4452efe-image.png

                  15864b21-df2d-46d2-902c-2ca336c454fc-image.png

                  f212cb91-a6f1-481e-b8c2-dcec0cd849cd-image.png

                  J Offline
                  J Offline
                  JoeCFD
                  wrote on 30 Aug 2023, 23:42 last edited by JoeCFD
                  #29

                  @8Observer8 It is the case of my app which has a lot of third-party libs. I had to add Android 13 SDK to make it run properly. But it is also true that 4 small libs I built with
                  Android 12 can still be used in Android 13. I guess different apps may require different SDKs. I did not spend a lot of time on it and simply made my app running.

                  1 Reply Last reply
                  0
                  • J JoeCFD
                    18 Aug 2023, 19:02

                    @8Observer8 then you need to add the support up to Android 13. Did you do it? Or you simply made Android 7 support?

                    my app supports Android 11, 12 and 13.

                    8 Offline
                    8 Offline
                    8Observer8
                    wrote on 31 Aug 2023, 00:09 last edited by 8Observer8
                    #30

                    @JoeCFD said in How to set up the FMOD audio library in Qt Creator for Android:

                    you need to add the support up to Android 13. Did you do it? Or you simply made Android 7 support?

                    It's not possible to only support Android 7 as Qt Creator won't let you uninstall the Android 12 SDK. If you try to uninstall the Android 12 SDK, Qt Creator will issue a message and install the Android 12 SDK again. FMOD is built in such a way that it will work on Android 13 as well. My example was very simple. It included only FMOD. I understand you just didn't have the time or desire to run it. But I now have two smartphones with Android 7 and Android 13, and I can test my games on OpenGL ES, OpenAL, Box2D and Bullet Physics. I don't need many libraries. These are enough. Qt already includes support for working with JSON, web sockets, and so on. I like OpenAL a lot more than FMOD. I haven't figured out how to use FMOD, but I don't need to - I don't want to waste time on it. OpenAL-Soft is the best for 3D audio because it's easy to install, free and open source.

                    1 Reply Last reply
                    0
                    • 8 Offline
                      8 Offline
                      8Observer8
                      wrote on 31 Aug 2023, 00:34 last edited by 8Observer8
                      #31

                      I tried FMOD, Bass, QMediaPlayer and OpenAL. For me, OpenAL is the best. I have made my choice. That's all for the audio library.

                      Now I will focus on translating my demos from pure WebGL 1.0 (Box2D-WASM/Ammo.js) to OpenGL ES 2.0 (Box2D/Bullet Physics) to run on Android and Desktop:

                      Pong game using WebGL 1.0, Web Audio API, glMatrix, FreeTexturePacker and JavaScript: https://8observer8.github.io/webgl10-js/2d-games/pong-2d-noobtuts-port-box2dcore-webgl-js/

                      pong-2d-noobtuts-port-box2dcore-webgl-js.gif

                      Multiplayer demo with Jill. This demo uses free hosting from Render.com. You must wait 15-20 seconds to start the server for the first time. The Node.js server on a free hosting falls asleep 30 minutes after the last activity.: https://8observer8.github.io/webgl10-js/room-webgl-js/

                      a48c30d7-283d-4813-a4e5-910777de9724-image.png

                      You can select "first person" and "third person" camera:

                      2eadd92c-2c46-41ba-84ff-a9e6a149ab54-image.png

                      Jill with lighthouse: https://8observer8.github.io/webgl10-js/simple-lighthouse-oimophysics-webgl-js/

                      b7acf15f-b511-43f4-bf2f-a421a483b26d-image.png

                      I extracted models, textures and animations from the original Resident Evil game. I imported them to Blender, exported to DAE (COLLADA), and import them to pure WebGL 1.0:

                      • Jill animations: https://8observer8.github.io/webgl10-js/re1/jill-animations-without-skinning-webgl-js/
                      • Barry animations: https://8observer8.github.io/webgl10-js/re1/barry-animations-without-skinning-webgl-js/

                      Super Mario (box2d-core) and Bomberman (Box2D-WASM):

                      260471712-18a9969b-275e-4f7c-8462-14ce990437c4.gif

                      Mario: https://8observer8.github.io/webgl10-js/mario-2d-jumps-box2dcore-webgl-js/

                      252929757-c609b42b-a07e-4177-a7c1-f59e57138b4f.gif

                      Output of English, Russian and Chinese fonts with stroke and Distance Field (the text is not pixelated when the camera zooms in) on JS and Rollup. Fonts converted to Distance Field using Hiero. Shadows was baked in Blender. Demo in the browser: https://8observer8.github.io/webgl10-js/shapes-with-text-webgl-js/

                      7f2b59ab-000b-47f5-aad7-2709c8f8e960-image.png

                      Click detection with color ID. Font in English and Russian. Dynamic shadow: https://8observer8.github.io/webgl10-js/door-with-ortho-shadow-map-webgl-js/

                      door-with-ortho-shadow-map.gif

                      Another demos I will be published here: https://8observer8.github.io/

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        Robert A. Navarro
                        wrote on 3 Nov 2023, 07:28 last edited by
                        #32

                        To set up the FMOD audio library in Qt Creator for Android, follow these general steps:

                        Download FMOD Studio:

                        Go to the FMOD website and download the FMOD Studio API package.

                        Install FMOD Studio:

                        Install FMOD Studio on your development machine.
                        Create a Qt Android Project:

                        Start a new Qt Creator project for Android or open an existing one.

                        Include FMOD Libraries:

                        Add the FMOD library to your Qt project. You can do this by adding the FMOD header files and libraries to your project's .pro file:

                        INCLUDEPATH += /path/to/fmod/api/lowlevel/inc
                        LIBS += -L/path/to/fmod/api/lowlevel/lib -lfmod

                        Android Permissions:

                        If your app requires audio permissions, add the necessary permissions to your AndroidManifest.xml file.

                        <uses-permission android:name="android.permission.RECORD_AUDIO"/>
                        <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

                        Initialize FMOD:

                        In your Qt code, initialize FMOD as early as possible in your application. You'll typically do this in your main function or at the beginning of your Qt application.

                        #include "fmod.h"
                        FMOD_SYSTEM* system;
                        FMOD_RESULT result = FMOD_System_Create(&system);
                        if (result != FMOD_OK) {
                        // Handle initialization error
                        }
                        result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0);
                        if (result != FMOD_OK) {
                        // Handle initialization error
                        }

                        Use FMOD in Your Application:

                        You can now use FMOD functions to manage and play audio within your Qt Creator project.

                        Build and Deploy:

                        Build your Qt project and deploy it to an Android device or emulator.

                        Please note that the specific paths, project configurations, and setup may vary depending on your Qt Creator project and the version of FMOD you are using. Make sure to refer to the FMOD documentation and your Qt Creator documentation for more details and any version-specific information.

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          Kim Nancy
                          wrote on 17 Jan 2024, 08:37 last edited by
                          #33
                          This post is deleted!
                          1 Reply Last reply
                          0
                          • 8 Offline
                            8 Offline
                            8Observer8
                            wrote on 19 Mar 2024, 17:59 last edited by 8Observer8
                            #34

                            @Robert-A-Navarro thank you for your answer. I want to try to run FMOD on Android again but before it I want to try to run it on Windows 10 with Qt6 MinGW 64-bit but I have the problem: undefined reference to `FMOD_System_Create'. My steps are below.

                            I downloaded "FMOD Engine" instead of "FMOD Studio" because I need "include" and "libs" only:

                            7b290758-fb5d-4477-a8b4-13a6207eaa74-image.png

                            This is the contains of the "lib/x64" folder:

                            6ee25835-cad8-4b72-a1f3-21cb64133fe7-image.png

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

                            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:

                            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
                            
                            jsulmJ 1 Reply Last reply 20 Mar 2024, 07:41
                            0
                            • 8 8Observer8
                              19 Mar 2024, 17:59

                              @Robert-A-Navarro thank you for your answer. I want to try to run FMOD on Android again but before it I want to try to run it on Windows 10 with Qt6 MinGW 64-bit but I have the problem: undefined reference to `FMOD_System_Create'. My steps are below.

                              I downloaded "FMOD Engine" instead of "FMOD Studio" because I need "include" and "libs" only:

                              7b290758-fb5d-4477-a8b4-13a6207eaa74-image.png

                              This is the contains of the "lib/x64" folder:

                              6ee25835-cad8-4b72-a1f3-21cb64133fe7-image.png

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

                              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:

                              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
                              
                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 20 Mar 2024, 07:41 last edited by
                              #35

                              @8Observer8 said in How to set up the FMOD audio library in Qt Creator for Android:

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

                              This is wrong. DLL files are used at runtime. To link your application you need LIB files. In this case it should be:

                              LIBS += -L"E:/Libs/fmod-2.2.21-mingw-64-bit/lib/x64/fmod.lib"
                              

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              8 1 Reply Last reply 20 Mar 2024, 08:32
                              1
                              • jsulmJ jsulm
                                20 Mar 2024, 07:41

                                @8Observer8 said in How to set up the FMOD audio library in Qt Creator for Android:

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

                                This is wrong. DLL files are used at runtime. To link your application you need LIB files. In this case it should be:

                                LIBS += -L"E:/Libs/fmod-2.2.21-mingw-64-bit/lib/x64/fmod.lib"
                                
                                8 Offline
                                8 Offline
                                8Observer8
                                wrote on 20 Mar 2024, 08:32 last edited by 8Observer8
                                #36

                                This is a solution for the absolute path:

                                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
                                

                                Andrew helped me here:

                                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.

                                But I need a relative path and I try it:

                                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 I have this error:

                                f6053d75-fbd8-46f4-b22a-23cd617beb50-image.png

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

                                52ee6446-2357-43de-ab1c-ae5ffc038e3a-image.png

                                @jsulm said in How to set up the FMOD audio library in Qt Creator for Android:

                                This is wrong. DLL files are used at runtime. To link your application you need LIB files.

                                But where will I find fmod.lib? There is no such file in the lib/x64 folder:

                                7eddc53e-7455-44bc-9e5a-ed519ea84962-image.png

                                I tried to use fmod_vc.lib instead of fmod.lib:

                                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
                                

                                But I have this error:
                                1422af12-20b2-4bda-845e-2dde481443e3-image.png
                                I try to use fmod with relative paths. I created the libs folder in my project folder. I don't want to copy fmod.dll to the Debug folder:

                                ffac2bab-4f56-4e86-a6cb-2b974726cdea-image.png

                                jsulmJ 1 Reply Last reply 20 Mar 2024, 08:35
                                0
                                • 8 8Observer8
                                  20 Mar 2024, 08:32

                                  This is a solution for the absolute path:

                                  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
                                  

                                  Andrew helped me here:

                                  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.

                                  But I need a relative path and I try it:

                                  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 I have this error:

                                  f6053d75-fbd8-46f4-b22a-23cd617beb50-image.png

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

                                  52ee6446-2357-43de-ab1c-ae5ffc038e3a-image.png

                                  @jsulm said in How to set up the FMOD audio library in Qt Creator for Android:

                                  This is wrong. DLL files are used at runtime. To link your application you need LIB files.

                                  But where will I find fmod.lib? There is no such file in the lib/x64 folder:

                                  7eddc53e-7455-44bc-9e5a-ed519ea84962-image.png

                                  I tried to use fmod_vc.lib instead of fmod.lib:

                                  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
                                  

                                  But I have this error:
                                  1422af12-20b2-4bda-845e-2dde481443e3-image.png
                                  I try to use fmod with relative paths. I created the libs folder in my project folder. I don't want to copy fmod.dll to the Debug folder:

                                  ffac2bab-4f56-4e86-a6cb-2b974726cdea-image.png

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 20 Mar 2024, 08:35 last edited by
                                  #37

                                  @8Observer8 said in How to set up the FMOD audio library in Qt Creator for Android:

                                  But where I will find fmod.lib. There is no such file in the lib folder

                                  I guess what you have is pre-build release. You need a development package, don't know where you can get it from. Maybe https://www.fmod.com/docs/2.00/api/platforms-win.html helps.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  8 1 Reply Last reply 20 Mar 2024, 09:04
                                  0
                                  • jsulmJ jsulm
                                    20 Mar 2024, 08:35

                                    @8Observer8 said in How to set up the FMOD audio library in Qt Creator for Android:

                                    But where I will find fmod.lib. There is no such file in the lib folder

                                    I guess what you have is pre-build release. You need a development package, don't know where you can get it from. Maybe https://www.fmod.com/docs/2.00/api/platforms-win.html helps.

                                    8 Offline
                                    8 Offline
                                    8Observer8
                                    wrote on 20 Mar 2024, 09:04 last edited by 8Observer8
                                    #38

                                    @jsulm said in How to set up the FMOD audio library in Qt Creator for Android:

                                    Maybe https://www.fmod.com/docs/2.00/api/platforms-win.html helps.

                                    Unfortunately, there is no new information for me here:

                                    The C API of the supplied libraries are compatible with MinGW (C++ ABI not supported). The 64 bit dll can be linked directly. You will need to use the import library libfmod.a and libfmodstudio.a in order to link the 32 bit dlls.
                                    Yes, I see it. There is libfmod.a in the x86 folder and there is no it in the x64 folder. This information that The 64 bit dll can be linked directly works for a relative path (even without copying 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
                                    

                                    But when I try to change the absolute set up path to the relative path:

                                    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 have this error:

                                    03d594c6-9658-4ae3-9171-109002472204-image.png

                                    It requires to copy 'fmod.dll' to the Debug folder.

                                    FMOD Core Engine library

                                    • /api/core/lib/$ARCH/fmod_vc.lib - Release binary for production code (requires fmod.dll at runtime).
                                    • /api/core/lib/$ARCH/fmodL_vc.lib - Release binary with logging enabled for development (requires fmodL.dll at runtime).

                                    Yes, it is true. It is really requires fmod.dll at runtime I tried to use fmod_vc.lib:

                                    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
                                    

                                    It works after copying fmod.dll to the Debug folder:

                                    86b18553-adbb-4925-a36c-883a82998f05-image.png

                                    It seams like I cannot use the relative set up path without 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
                                    

                                    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:

                                    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
                                    
                                    1 Reply Last reply
                                    0
                                    • 8 Offline
                                      8 Offline
                                      8Observer8
                                      wrote on 20 Mar 2024, 09:59 last edited by 8Observer8
                                      #39

                                      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
                                      

                                      widget.h

                                      #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

                                      #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()
                                      {
                                      }
                                      

                                      main.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

                                      <RCC>
                                          <qresource prefix="/">
                                              <file>assets/audio/overworld.ogg</file>
                                          </qresource>
                                      </RCC>
                                      
                                      jsulmJ 1 Reply Last reply 20 Mar 2024, 10:05
                                      0
                                      • 8 8Observer8
                                        20 Mar 2024, 09:59

                                        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
                                        

                                        widget.h

                                        #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

                                        #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()
                                        {
                                        }
                                        

                                        main.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

                                        <RCC>
                                            <qresource prefix="/">
                                                <file>assets/audio/overworld.ogg</file>
                                            </qresource>
                                        </RCC>
                                        
                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 20 Mar 2024, 10:05 last edited by
                                        #40

                                        @8Observer8 If you want to run your app outside of QtCreator you first have to deploy it, so it contains all needed libraries.

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        8 1 Reply Last reply 20 Mar 2024, 11:19
                                        0
                                        • jsulmJ jsulm
                                          20 Mar 2024, 10:05

                                          @8Observer8 If you want to run your app outside of QtCreator you first have to deploy it, so it contains all needed libraries.

                                          8 Offline
                                          8 Offline
                                          8Observer8
                                          wrote on 20 Mar 2024, 11:19 last edited by 8Observer8
                                          #41

                                          @jsulm 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:

                                          eb019c85-e68a-4755-beca-8b693bb71c2b-image.png

                                          jsulmJ 1 Reply Last reply 20 Mar 2024, 12:01
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved