I am developing a multiplatform (Windows, Linux and Mac) Qt based Phonon C++ application and am aware that Phonon itself is only API, which relies on a backend to interact with installed codecs.
Logically, I should assume that the end user has no extra codecs installed, only those provided by OS.
So my question would be, is it possible to bundle an OGG (preferably) or AAC decoder with my application so that the backend would recognize it and be able to play audio files? What steps in general should I take and where to look for more information on this?
The application itself is not installable, it runs directly form physical media.
Sound Libraries for C++
As far as getting the right libraries for playing sound, it should just be a matter of finding out what libraries are used by Phonon on your system. I know Phonon is a pretty big project and each OS has a different set of drivers for playing media and using Codec, etc. I would suggest looking at Audacity and VLC and checking Google.
Plugins/Libraries and Qt
As far as getting Phonon to work with Qt, I have experience there...
I haven't done a ton of testing with Phonon on every major OS, but I have on a few different versions of Windows.
The deployment of a Qt Application is very straight forward, even with plugins and libraries like Phonon. But figuring it out the first time was a little painful, just because the jargon is a little weird.
My answer is in the context of a Windows Desktop Application with Dynamic Linking to the Qt Libraries, not static.
Here is the directory structure for windows and a short explanation of how dlls are found.
Deploying a Qt Application
Dynamic-Link Library Search Order in Windows
For Mingw on Windows in the Qt SDK there is a folder for its binaries, and in that folder there are the dlls that your application needs to be able to find at runtime (If you are doing Dynamic Linking). I usually put these DLL's in the same folder as the Application EXE that I build in Qt creator and then keep the "Working Directory" or the directory that the EXE is ran from to be the same directory as well.
For the additional plugins/libraries that are for specific media types, like image formats and for phonon, you need to have a specific structure that your application can find it in.
You can make some very specific ones for your application and add them using the functions related to this call.
QStringList QCoreApplication::libraryPaths()
In general mimic the directory structure that you find in the MingW "plugins" folder for the additional dlls you need.
For example, I wanted to be able to show a system tray icon properly. Apparently you need the correct image format engine plugin to show the icon. (qgif4.dll, qico4.dll, and qjpeg4.dll)
Here is were the plugin was located on my developing machine:
"C:\QtSDK\Desktop\Qt\4.7.3\mingw\plugins\imageformats"
Here is where I place it so that it can be found at runtime:
"C:\path\to\my\EXE\imageformats"
or
".\imageformats" (relative to my working directory of my EXE)
What is one of the more annoying things about discovering this information, is that the plugins don't fail in the same way as the main Qt Libraries, so you don't see it broken until you get to the part of your program that is actually attempting to use them.
Generally, you could supply the VLC Phonon backend for Windows. The default DirectX backend is unfortunately quite limited.
On Linux, you can assume that a suitable Phonon backend comes with the OS's Phonon installation. The two backends currently popular are GStreamer and VLC.
Related
I have written windows gui application using qt and i want to deploy it.Now when i place .exe to other PC it shows error which says that qt5core.dll and etc required.I can install this dll,but is it possible to run exe app with qt without qt's dll as one file?So i can for example give .exe to my friend and he can instantly run it without installing .dll?
Basically, if you want a single exe file, you probably mean static linking.
The legal commercial version makes it possible or if I am not wrong, you will have to build a static qt version.
In the latter case, you will have to provide the source code of your application.
I do this sometimes, but you'll have to be careful with the license requirements: if you go with GPL, it should be OK, if you choose LGPL, it may be a bit less simple. No idea about the commercial version.
What you must do is building Qt statically, and then use that Qt build to build your application. I had a good experience with mxe. MXE builds an entire crossbuild environment and allows you to build your big Qt exe statically. I used it on Mac OS and Linux to build static executables for Windows, but you can probably run it on WSL. It takes a bit to compile, but it is simple to use. Please note that it cannot be used if your app needs QtWebEngine as it won't build with mingw.
Another simpler option is to create an installer. The Qt installer framework is simple to use. If you include the VS runtime, you end up with a single exe to distribute (the installer).
You always need to include the libraries you use (including your compilers runtime libraries in fact) when you deploy your executable - otherwise how would your application be able to use the code in those libraries? You may be able to statically link some/most things, but rarely everything. Look into how to create an installer / package for your application, so you can bundle up everything as one convenient file.
You can buid you app using QT Static (a large .exe file, no external dependencies)
If you are using LGPL Qt, you must read this:
https://www.qt.io/faq/3.7.-what-are-my-obligations-when-using-qt-under-the-lgpl
Yo can use Qt and static linking, but "The user of your application has to be able to re-link your application against a different or modified version of the Qt library"
You can use an application template like this, very useful for LGPL Qt:
https://marketplace.qt.io/products/qt-lgpl-app-template
I developed a Qt application in MacBook (El-Capitan 10.11.2) and it is ready now to be released.
What i want now, is to create the standalone executable file for both Mac and Windows OS.
But I don't know how !
I found this link but I am unable to follow it is guidance, it looks different from what my system is showing me.
If you have any idea, please help me.
Thank you
Well, to compile an application for windows, you will need a windows machine (or at least a virtual machine). You can't compile for windows on mac.
Regarding the "standalone": The easy way is to deploy your application together with all the required dlls/frameworks and ship them as one "package". To to this, there are the tools windeployqt and macdeployqt. However, those will not be "single file" applications, but rather a collection of files.
If you want to have one single file, you will have to build Qt statically! You can to this, but you will have to do it on your own. And if you do, please notice that the LGPL-license (the one for the free version of Qt) requires you to make the source-code of your program public! That's not the case if you just link to the dynamic libraries.
EDIT:
Deployment
Deployment can be really hard, because you have to do it differently for each platform. Most times you will have 3 steps
Dependency resolving: In this step, you collect all the exectuables/lirabries/translations/... your application requires and collect them somewhere they can find each other. For windows and mac, this can be done using the tools I mentioned above.
Installation: Here you will have to create some kind of "installer". The easiest way is to create a zip-file that contains everyhing you need. But if you want to have a "nice" installation, you will have to create proper "installers" for each platform. (One of many possibilities is the Qt Installer Framework. Best thing about it: It's cross platform.)
Distribution: Distribution is how to get your program to the user. On Mac, you will have the App-Store, for windows you don't. Best way is to provide the download on a website created for this (like sourceforge, github, ...)
I can help you with the first step, but for the second step you will have to research the possibilities and decide for a way to do it.
Dependencies
Resolving the dependencies can be done by either building Qt statically (this way you will have only one single file, but gain additional work because you will have to compile Qt) or using the dynamic build. For the dynamic build, Qt will help you to resolve the dependencies:
macdeployqt is rather easy to use. Compile your app in release mode and call <qt_install_dir>/bin/macdeployqt <path_to_your_bundle>/<bundle>.app. After thats done, all Qt libraries are stored inside the <bundle>.app folder.
For windeployqt is basically the same: <qt_install_dir>\bin\windeployqt --release <path_to_your_build>\<application>.exe. All dependencies will be inside the build folder. (Hint: copy the <application>.exe in an empty directoy and run windeployqt on that path instead. This way you get rid of all the build-files).
Regarding the static build: Just google it, you will find hundreds of explanations for any platform. But unless you have no other choice but to use one single file (for whatever reason) it would recommend you to use dynamic builds. And regarding the user experience: On mac, they won't notice a difference, since in both cases everything will be hidden inside the app bundle. On windows, it's normal to have multiple files, so no one will bother. (And if you create an installer for windows, just make sure to add a desktop shortcut. This way the user will to have "a single file" to click.)
I'm working on a collaborative project in Qt Creator, and I've managed to get it to compile: I linked CEF Framework and the CEF dll wrapper. However, when I try to run it I get:
dyld: Library not loaded: #executable_path/Chromium Embedded Framework
Reason: image not found
As far as my understanding goes, the framework needs to be copied into my DEST_DIR, into .app/Contents/MacOS or something like that. I have NOT managed to make it work even by copying the framework there manually.
Also, since the development is meant to be cross platform, I was wondering if there's a way to tell qmake how to copy the framework to my DEST_DIR.
Any help in understanding how to deal with frameworks on Mac OS X in Qt Creator would be greatly appreciated.
As far as my understanding goes, the framework needs to be copied into my DEST_DIR, into .app/Contents/MacOS or something like that.
You're nearly there. Frameworks are generally copied into
.app/Contents/Frameworks
However, your bundle's executable contains a reference to where it expects those framework libraries are residing and having copied them into the app bundle, you need to tell the executable where they are.
Using oTool with -L argument, you can see the libraries referenced by the executable. You'd call it with the full path. For example
otool -L /Applications/Calculator.app/Contents/MacOS/Calculator
For each dylib in the framework, you need to fix up the path using the command line tool install_name_tool
When deploying a Qt application for Qt, we must run the macdeployqt. This essentially does the same thing for the Qt Frameworks; copies them into the relevant Frameworks folder and updates the paths.
I've not used it myself, but according to the documentation, macdeployqt supports handling 3rd party frameworks, with the option -executable=< path >
I have a basic C++ applicatin build using g++ and -framework ...
when I run it, I get a :
Working in unbundled mode. You should build a .app wrapper for your Mac OS X applications.
(which is not std::couted by any of my application).
What causes this, and how can I get rid of it?
Thanks!
You need to create a folder structure and place the binary in a special location. For an example with explanation see this Qt page
Mac OS X handles most applications as "bundles". A bundle is a directory structure that groups related files together. Bundles are used for GUI applications, frameworks, and installer packages. These are presented to the user as one file in the Finder. When set up correctly, bundles make for easy deployment. All one needs to do is to archive the application using some preferred method. Users then open the archive and drag the application to wherever they please and are ready to go.
There is something written about this for wxWidgets too
MacOSX introduces a new way of putting together an application. Instead of adding a resource fork to the executable file, you can simply create a special directory (folder). This is the preferred method for OSX.
I'm developing a cross-platform app w/ wxWidgets and opengl...
I'm not sure what the best way is to have fonts work in the glcanvas. I've tried using FTGL but I think the version included in Fedora 11 must be broken or something since I can't get the example code on the web site to compile. I could try using GLUT or SDL but I'm not sure I want to include those as dependencies...
EDIT: Turns out it's just a different version than the one that is documented on the web site and has a completely different API.
Even if I have a font library though, all the ones I've seen require a path to a font file, and I have no idea how to do that in a cross-platform manner.
All platforms deal with fonts differently. There is no cross platform way to find fonts on a system. Alternatives include...
Package your fonts with your app so you know where they are.
Convert the fonts to a binary blob and embed them in your app.
Test for the OS and set the font path accordingly.
Transliterate this tutorial to C++ and array-embed a gzipped copy of the GNU Unifont. QuesoGLC might also be an option, but watch out for performance gotchas.