Xcode compiling app without images SFML - c++

I finished working on a Mac application. This application has been coded in Xcode. It used multiple images and fonts that formed the GUI. When I was adding these images, I had to put them in the directory of the debug file to be loaded (just placing them in the sidebar didn't work). Now, when I exported the application to my desktop, the app didn't load any images or fonts. I even tried adding the images to the same directory, but still none were loaded. Do you know what might be the issue? Perhaps, where should I place the files?
When the application is compiled within Xcode, everything works well, all the images are loaded. When I open the app in the debug directory, no images are loaded. And, if exported, still no images are loaded.
I don't know whether this is the issue with archiving, but I noticed that my SFML frameworks are displayed in red in Xcode. I don't know why as the framework directory is set correct, however the frameworks do load during build.

The problem is that you need to get the xcode 5 templates from the website and then put those into the developer folder in your lib.

Related

How to make XCode bundle C++ project as an .app?

A few months ago, I inherited a C++ command-line XCode project that I've since turned into an app with a GUI, but XCode won't build it as an .app bundle:
Instead, XCode builds a Debug folder, which, interestingly enough, works as an app if I copy it and rename it to "[Bundle Display Name].app".
There are two problems with this though:
(1) I have to manually do this for each build
(2) It doesn't link to my Assets.xcassets file containing my app icons or my Info.plist file or any of the other resources I need.
I've scoured Apple's XCode documentation and come up with nothing. Are there any XCode veterans who know the solution?
EDIT: It seems like the only solution is to add a script to the Build Rules to manually change the Debug directory to an .app and structure it properly. The problem I'm now having is that my app doesn't see my .icns file unless the absolute path is hardcoded into the Info.plist file. For example:
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
^This doesn't work
<key>CFBundleIconFile</key>
<string>/Users/.../build/Control Cam.app/Contents/Resources/AppIcon.icns</string>
^This works. But of course it can't find the icon anymore if I move the app to a different folder. Any ideas how to get it to use relative path names?

Error when launching application

I have rebuilt the QGIS code on VC2008 on Windows 7.
I have all the correct DLLs in the folder of the exe, and can see that it knows where the QT DLLs are.
When I launch the app, I get this error:
The procedure entry point ??4QPixmap##QAEAAV0#$$QAV0##Z could not be
located in the dynamic link library QtGui4.dll
I'm not sure where to start to get this working. I checked the QtGUI4.dll to see that it is loading, with a dummy app. It seems fine.
Any help would be great.
Posting it as an answer since my hunch turned out correct:
This error shows that your application was loading the wrong Qt DLLs. For whatever reason, it was finding and loading DLLs different from the DLLs against which it was built. In your case it turned out it was finding Qt4 built for VS2010 DLLs, while it needed Qt4 built for VS2008.
The solution is to make sure it always finds the correct DLLs - place the correct DLLs in the EXE's folder, as this is usually the first place it looks for for DLLs. On Windows, it's not a good idea to rely on %PATH% or on the current directory.

Code Blocks: not loading images when launched out of compiler

I made an application in code blocks that loads images. These images are in folder, placed in root directory of the .cbp file. When I compile & run the application, the images load without a problem. However, when I launch the application from the debug folder (where app is created), the images aren't loaded. Am I doing it the right way? I mean, isn't there a button to finalise an application that would prevent this issue?
Thanks.
If the Debug Folder is in the same directory as your cbp file, and the executable is in the Debug folder, do: "../Folder/pic" You see, ".." basically means "look one directory up"
Edit: Alternatively, you could copy the folder with your images to the Debug Folder too. Then it would be in the so called "working directory" of the application again.

Deploying Qt application using QtMultimedia in release mode

I am developing a Qt 5.0 dekstop application using mingw47. I use QtMultimedia in this application to record and play audio. I have tested it for debug and it works. When I try to build it for release and run the executable file, I can't play the audio file that can normally be played in debug mode. I've added the following dlls before running the executable file:
D3D_Compiler_43.dll,
icudt49.dll,
icuin49.dll,
icuuc49.dll,
libEGL.dll,
libgcc_s_sjlj-1.dll,
libGLESv2.dll,
liblibmpeg2_plugin.dll,
libstdc++-6.dll,
libwinpthread-1.dll,
Qt5Core.dll,
Qt5Gui.dll,
Qt5Multimedia.dll,
Qt5Network.dll,
Qt5Widgets.dll,
Qt5Xml.dll,
plugins/platforms/(all dlls),
plugins/mediaservice/(all dlls),
plugins/playlistformats(all dlls)
What is probably wrong? Or what other dlls am I missing?
UPDATE: Use windeployqt.exe! It works really well.
http://doc.qt.io/qt-5/windows-deployment.html#the-windows-deployment-tool
The simplest way to use windeployqt is to add the bin directory of
your Qt installation (e.g. ) to the PATH variable and then
run:
windeployqt <path-to-app-binary>
While you are running your application in release mode (when it is working, ran from inside Qt Creator), execute depends.exe and point it at the application.
Make note of all the dlls that are referenced from your Qt folder.
Alternate way if you want to take more time with it:
You can figure it out by hand by trying to delete files because Windows won't let you delete a folder or a dll while it is in use. So you could go and make a back up of your Qt installation, and then run you application, make sure it has connected to all the dll's it is going to use, and then try to delete folders and files in your Qt installation. Windows won't let you delete files that are in use by your release.
Also here is how Windows resolves dll's if you wanted to know:
http://msdn.microsoft.com/en-us/library/7d83bc18(v=vs.80).aspx
EDIT: Also, you don't need to make the folder called plugins in your exe directory. It should be something like this:
Qt 4.x:
./myexe.exe
./QtCore.dll
./imageformats/qjpegd4.dll // Note: there isn't a "plugins" folder here
Qt 5.x: (take from here)
The executable ./plugandpaint.exe
The Basic Tools plugin ./plugins/pnp_basictools.dll
The ExtraFilters plugin ./plugins/pnp_extrafilters.dll
The Qt Windows platform plugin ./platforms/qwindows.dll
The Qt Core module ./Qt5Core.dll
The Qt GUI module ./Qt5Gui.dll
The Qt Widgets module ./Qt5Widgets.dll
Also run qDebug() << QApplication::libraryPaths(), and make note of paths that are searched for dlls on your computer.
Hope that helps.
All of the DLL's in your list that have their import libraries linked to the application will be automatically loaded by the OS. If any of them are missing you will get a dialog telling you which DLL it failed to load. The only ones that look like they might be loaded manually by the application are the plugins. Make sure you are telling the QT multimedia system to load the them. Also make sure you check the error codes returned by the multiamedia manager.
Given your recent comment that the audio plays in debug mode but not in release mode is a good indication you have put the plugin DLL's in the wrong place. When you launch your application from Explorer or the command line the plugins directory needs to be in the same directory as the application. Your directory structure should look something like below
c:\stackoverflow\myprogram.exe
c:\stackoverflow\plugins\platforms\(all dlls)
c:\stackoverflow\plugins\mediaservice\(all dlls)
c:\stackoverflow\plugins\playlistformats\(all dlls)
c:\stackoverflow\D3D_Compiler_43.dll
c:\stackoverflow\icudt49.dll
... other dll's here...
c:\stackoverflow\Qt5Network.dll
c:\stackoverflow\Qt5Widgets.dll
c:\stackoverflow\Qt5Xml.dll
I've found the answer. Now my application works. It can play audio file while running the executable file.
Although not listed in depends.exe, we should add the following dlls when using QMediaPlayer:
Qt5MultimediaWidgets
Qt5OpenGL
Here is the reference: https://bugreports.qt-project.org/browse/QTBUG-30172

Icons disappear on an other computer

I've created a program with Qt Creator and compiled it with the release mode.
I've added all the necessary DLLs and everything runs fine on my computer.
The problem is that when I start the program from an other computer all the icons that I've included are not displayed, whereas everything looks fine on my computer.
Where can this come from?
Edit: The icons are loaded in a qrc file...
Most of Qt's support for file formats relies on plugins. To ensure that your application works as expected when deploying it on non-development machines, you will have to make sure that you have also deployed the relevant plugins. If you haven't, the loading of files (ICO icons in this case) will simply fail silently.
The plugin of importance in this case is qico4.dll (if you're on Windows).
The official Qt documentation contains all the relevant information on Qt deployment for both Windows and Mac. Scroll down to the relevant information on Qt plugins.
As a quick solution you could create a directory named imageformats as a subdirectory of the folder containing your executable, into which you copy the qico4.dll.
(Note: user #smerlin says this has to be plugins/imageformats relative to your executable directory. I seem to recall that my applications did not require the extra plugins directory, but I'll update my answer should I find that this is indeed the case).