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

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?

Related

QT Deployment error

I am trying to deploy a QT5.4.1 appplication on Windows 7 - x86.
As always, everything is working fine on my machine, but not in the end user's machine.
When I try to run the app, it gives me the following error:
After searching on the internet, most solutions say that I need to add a platforms folders containing some dlls (qminimal, qoffscreen, etc) to the deployment package. I tried that with no success.
The funny thing is that I copied QT installation folder to the end user machine and deleted everything except this folder (C:\Qt\Qt5.4.1\5.4\msvc2012_opengl\plugins\platforms) and it works fine.
So, somehow my app is looking for the platforms folders in QT installation folder instead of the deployment package folder.
Does anyone know how to solve it?
EDIT:
I have managed to change all QT Dlls to the release version (without "d" sufix). However, when i compile my project I still get some vc++ dlls in debug mode. I checked all project configurations in both "linker" and "c/c++" sections and they all use "release" configurations. When I run the program, It gives me a "debug assertion failed". Why I am getting the debug versions of vc++ dlls?
Here is the dependency walker screenshot
The comments of Mezzo seem very relevant. We regularly deploy commercial Qt Windows applications. You could use dependency walker to find the dependencies or just double click on the executable and look at the Windows complaint about what dll's are missing. Just copy them to the deploy location, preferably with a qmake script.
The plugin dll's are more difficult to deal with. They do not show up as dependencies. The operating system could complain about their absence (dll's located in the subdir "platforms" for instance) or your application might just not use their functionality (dll's in the subdir "imageformats" for instance) without any complaint. To protect yourself against the latter case you have to test drive your application thoroughly.
Windows does not need a qt.conf file. Just create the subdirs "platforms", "imageformats", ... in the application dir and copy the plugin dll's there. As an example I show the full content of an (mingw) application dir that even when copied to a virtual machine runs without any problem.
Qt5Btc1.dll is our own dll.
I figure out what is wrong, although I don't have the solution yet. Even without the solution, I think this answer might be helpful.
My project output is a DLL that has a GUI made in QT.
Another program calls this DLL and during DLL_PROCESS_ATTACH a QT GUI is created.
According to the documentation, QT looks for the plugins in:
in the directory containing the application executable, i.e. > QCoreApplication::applicationDirPath() + QDir::separator() + "qt.conf"
That´s why the QCoreApplication::applicationDirPath() is not the deployment directory where the DLL is located, but the directory where the external program *.exe is running. I think QT is looking for the qt.conf file in this *.exe location
EDIT: there is nothing to do with debug or release versions

Qml program does not run

I've build qt for static linking to make just one exe without any dll's, configured creator. On my computer everything works. But when i run a program on other computers nothing happens. Process starts, but nothing is shown. And it's only with qml, it works with c++ projects.
I tried to make a simple exe and add all needed libraries by windeployqt, but it doesn't change anything.
Maybe someone can tell me, what am i doing wrong?
I have found that with QML applications you might need directories from the following directory:
..\Qt5.3.2\5.3\msvc2013_opengl\qml\
The directories needed depends on what you have included.
For my application I had the following structure:
my.exe
QtGraphicalEffects
QtQuick
QtQuick.2
First run the mingw on cmd terminal of windows (on my case it is on C:\Qt\6.1.1\mingw81_64\bin).
After this go to your project output (where is your .exe file that you want to run on another windows machine).
Run the windeployqt command:
windeployqt.exe --qmldir C:\Qt\6.1.1\mingw81_64\qml .
I run the example project "Qt Quick Application - Scroll".
The blank screen only happens on PCs that do not have a video card with OpenGL 2.0 support.
Try this:
1. Used dependency walker(http://www.dependencywalker.com/) to see the exact path of the dlls needed. Try it because both QtCreator and QT framework both have the same dlls and you must pinpoint the exact ones used. I copied all dlls needed in the same folder as the app.
2.I have copied the folder platforms from QT framework /plugins and copied it in the same folder as the app. Now the app comtained also plugin/platform/ folder with all its dlls
3.And the most important step in my case is to create a file named qt.conf in the same folder as the app . This file should contain the path to the plugins. My qt.conf file contains:
[Paths]
Libraries=../lib/qtcreator
Plugins=plugins
Imports=imports
Qml2Imports=qml
Try copying every DLLs in below folder to the folder where your exe is.
C:\Qt\x.x.x\msvc20xx_xx\bin\
If the exe runs normally, try deleting the DLLs some by some to find out what dll is needed and what is not needed.

failed to load platform plugin "windows" Available platforms are: windows, minimal

Hi Im trying to execute my .exe file from the debug folder.
Now before you go telling me about all the other related articles Ive looked at them all and their solutions are not helping with my problem.
Ok first off Im using Qwt library and trying to create a set of gauges. I got a gauge working now I need to get it to execute from the .exe.
Ive tried adding the platforms folder in with my directory and adding the windowsd.dll and minimald.dll but still does not work.
Please advise on any course of action this had got me stumped.
Also one post says to create a qt.conf file and place it in the directory but I cant find out how to make a .conf file.
UPDATE
the error reads
debug error!
Program:
...build-Desktop_Qt_5_0_1_MSVC2010_32bit-Debug\debug\gauge.exe
Module:5.0.1
File: kernel\qguiapplication.cpp
Line:781
Failed to load platform plugin "windows". Available platforms are:
minimal
Windows
When deploying Qt on Windows, you have to copy over a number of the dlls from the bin folder of the Qt directory.
On my system it is:
C:\Qt\4.8.4\bin
After you copy over all the required dll's from there, like QtCore4.dll and QtGui4.dll, if you are using any additional plugins like phonon or jpeg support, you need to copy those dll's over from the plugins folder:
C:\Qt\4.8.4\plugins
For example I make a folder in the folder with my exe called imageformats and I put qjpeg4.dll in that folder.
As far as Qwt works, you probably need to do a similar process to expose those dll's to your exe, and put them in the same folder as your exe.
The dll's listed above are for the "release" build of your exe. If you are running the "debug" version, it will look for <dll_name>d.dll.
The reasoning for putting in those paths has to do with the library search order that windows uses.
Qt, Phonon and multimedia codecs: how to bundle them?
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx
http://qt-project.org/doc/qt-4.8/deployment-windows.html#creating-the-application-package
Hope that helps.
If you have several executable and\or you don't want to copy plugins by hand, you can create a qt.conf file with the path to the plugin directory
[Paths]
Plugins = PATH_TO_QT_DIR/plugins
You need to place the qt.conf file where the executable is.
More information at http://doc.qt.io/qt-5/qt-conf.html

Setup cocos2d-x application through visual studio 2010 project template

I'm trying to setup an application on Windows 7 using Cocos2D-x.
I followed this tutorial.
I did the following:
Built the library running Build-win32.bat script. Works.
Installed VS2010 project template. Works.
Run successfully all test programs.
Created a new cocos2D-x project through the installed template. Works
When I compile the Hello World application I have the follwing errors:
error C1083: impossible to open inclusion file 'CCstdC.h' No such file or directory
error C1083: impossible to open inclusion file 'cocos2d.h' No such file or directory
It's a wrong include path.
I could fix it by manually modifying include path but since I'm creating project through the template I-d like to solve this, possibly not having to modify paths manually for each new project I'll create.
Did anyone ever had the same issue?Do you know how to fix this?
Well, I setup cocos2dx projects like this:
create an empty win32 app in VS
open the folder contains your .sln file (your solution folder)
open the cocos2dx package (i.e. cocos2d-1.0.1-x-0.12.0.zip) with 7z or something
drag cocos2dx, and optionally CocosDenshion, Box2D, etc. to your solution folder
add cocos2dx project (cocos2dx\proj.win32\cocos2d-win32.vcxproj) into your solution
go to your project's properties, select C/C++->General, add the following entries to your Additional Include Directories option:
..\cocos2dx; ..\cocos2dx\include; ..\cocos2dx\platform; ..\cocos2dx\platform\win32; ..\cocos2dx\platform\third_party\win32\OGLES
and ..\CocosDenshion\include if you're using the SimpleAudioEngine
in the Linker->Input->Additional Dependencies option, add libcocos2d.lib, and libCocosDenshion.lib if you use the audio engine; in the Linker->General->Additional Library Directories option, add $(OutDir)
go to the Configuration Properties->General->Output Directory option, set it to $(SolutionDir)\build\
open the project property for cocos2d library, go to the Configuration Properties->General->Output Directory, set it to $(SolutionDir)\build\, also do that to the rest of the libraries you included.
All set, you're ready to go.
Unfortunately that template is not that useful. I believe that in a previous version of cocos2d-x (the one that tutorial is based on) the paths were absolute, and referenced the cocos2dx, cocosdenshion projects directly.
Now, as they're relative (..\..\cocos2dx), and they are not copied to the solution directory when a project is created, it just doesn't work.
You could obviously fix the paths (as you suggested) but my suggestion is: copy the HelloWorld project and use it as a template. The solution structure is much better than the one in the template as it's already prepared for iOS, win32 and Android. Trust me, can't get any easier than that.
Now, here's the catch: if you copy the HelloWorld project to a sibling folder, you're done, as all the references are already setup. If you want to copy to other place you'll have to also copy cocos2dx, cocosdenshion along, leaving the target structure like:
target_path\cocos2dx
target_path\cocosdenshion
target_path\Copy_of_Hello_World
I solved opening the cocos2dx library solution and add to it a new project through VS template wizard.

Qt not working correctly

I have just installed Qt_SDK_Win_offline_v1_1_4_en.exe and run QT Creator.
I am working on Win7 64 bit.
I wanted to make simply app with form and button on it to test Qt. I choose New->Project QT Widget->Aplikacja Gui QT ---> then Desktop application.
When I run Play Button - that should build and run the application I get a message: that I should check path and privileges. I can't also run the exe files as administrator manually because windows give me message that I don't have privileges. I gave full privileges in file Properties but then after run I am getting error that I don't have mingwm10.dll.
I gave full privileges in file Properties but then after run I am getting error that I don't have mingwm10.dll.
This means the library required can't be found in any of the locations Windows searches to find libraries. The usual method to get around this is by making sure the folder containing the copy of mingwm10.dll which the Qt SDK installs is in your PATH environment variable. Here is one of the many Google-able guides to settings those variables.
Ok, I found a partial solution, I could finally run the exe file.
First, something must have changed in my Windows7 because every new created folder (and files in it)had restrictions and noone could make all operations.
So, after changing properties of folder, I got message about missing dlls files, so I started to copy them from QT folder. There are at least a few different versions of each dll, and only one is correct, so I copy those form mingw folder bacause I used mingw compiler, and finally after copying 4-5 dll I run the exe file.
But this is not what I am expecting from app that install pack has almost 2GB...
thanks
m.