Setting up release build viable directories in QtQuick
-
Hi,
I'm trying to deploy my qt app for a test run, but I have some paths in the app that need to be hard coded to work with the Miniaudio library. When I use windeployqt on a release build, "Sounds/testsoundA.wav" becomes invalid, due to how the folders are rearranged; the path no longer exists.// "Sounds/testsoundA.wav" will fail via release build ma_result soundResultA = ma_sound_init_from_file(&engine, "Sounds/testsoundA.wav", 0, &sfx, NULL, &testSoundA);
Release build directories often differ from the directories in the debug build, so even though this runs in the debug build, I expect this to fail after I use windeployqt on the release build. How can I get hardcoded paths to work with the final release? Or if they won't, what can I do to have my c++ pick up on the new directory for my audio?
CMAKE:
qt_add_qml_module(appxxx URI xxx VERSION 1.0 QML_FILES Main.qml UI.qml TestObject.qml CustomFonts.qml RESOURCES Sounds/testsoundA.wav }
-
I would suggest, you use the Qt Ressourcen System:
https://doc.qt.io/qt-6/resources.htmlthat will bake your wav file into the executable and the path will always be the same. It's the solution if you work with read only access
in a c++ backend you also have the option to use, https://doc.qt.io/qt-6/qstandardpaths.html and QStandardPaths::ApplicationsLocation and then relative paths
-
-
Awesome, thanks for the insight!