I'm very familiar with MS's Visual Studio environment, and recently I had to do some stuff for iPhone. I have a c++ project and I have performance critical components included as part of the project. This performance critical file absolutely must be compiled using optimized settings even for debug builds. That is, I have to overwrite settings for a file and pass -O2 -DNDEBUG when compiling one of the files of the project without affecting default compilation settings of the rest of the project.
Can this be done, I spent like an hour browsing through menus of XCode and wasn't able to find it!
If you go to your project window and select the file, you can get info on it with command-i or right clicking. Then go to the build tab, where you can enter additional compilation flags for this particular file.
I am on xcode 3.x but I don't imagine that they would remove this.
I note that this is just for additional compiler flags. If you need to remove some of your default flags the only option I can think of is a bit of a pain: make a new target that is set up with build options just for this file and include that target in your main target.
Related
Update:
Because this was partly to have a project to code-browse the whole of qt, here is a much better way to do this: Code Browser by Woboq for C & C++
This even lets you browse into the includes outside the project like the system includes or the standard library.
Old Post:
My question is about Qt project in git://code.qt.io/qt/qt5.git repository. I checked out version 5.12.
My assumption is that qtcreator knows the qmake file but nothing about the configure command. Hence
I used the configure command to prepare the build in a shadow build directory
In QTCreator I opened qt.pro located in the git workspace
QTCreator opens the build settings dialog and I import them from the shadow build directory
Finally I click build in QTCreator.
But the compile window stalls when asking me for input. Qmake asks me about the licence type I want to choose. I had answered that already in the configure phase and even if I would agree to answer the question again, there is no prompt function in qtcreator's compile output window. Where did I go wrong?
If I forget about QTCreator and call make in the shadow build directory, then everything is build fine and without any licensing questions. When I then import the shadow build directory into a QTCreator, then I can build in QTCreator. But then I clicked Run qmake out of curiosity and I was back to square one, i.e. compile window asks me for input again and stops there forever.
Apart from my specific question I found no general documentation about building the qt libraries using QTCreator. I only find descriptions about compiling projects that use the Qt library.
Qt is not really meant to be compiled from within an IDE. However, this does not mean it's impossible to do. There are two ways to archive this:
First approach: Add the developer build as custom kit:
Run the configure script (and add the -developer-build option)
Open QtCreator and go to "Tools > Options > Kits"
Go to "Qt Versions" add press "Add" - select the qmake executable generated by the configure script. Then hit "Apply"
Go to "Kits" and press "Add" - Make shure to select the correct compilers and debugger and select the previously create "Qt Version". Press "Ok"
Open the top level .pro file in QtCreator and choose the previously created Kit. QtCreator will now use the correct qmake executable
This is the "proper" way to go. You can now use the project as any normal project, including changes to pro-files. Also, QtCreator now correctly detects the build directory, so you won't have to change that, even when opening one of the modules.
Second approach: Use as a normal project without qmake:
Run the configure script (and add the -developer-build option)
Run make qmake_all in the same terminal to let Qt prepare all makefiles, create headers etc.
Open the top level .pro file in QtCreator. You can choose any kit.
Go to Project > Your Kit > Build and disable the "qmake" step (the first of the default 2 steps)
Change the "build directory" to be wherever you built Qt - either a shadow build or the source directory
Hit Build and QtCreator will invoke make only, archieving the same behaviour as running make from the console.
This is kind of a workaround and I would not recommend using it for a full Qt build, unless the first approach does not work for you for whatever reason.
This can also be useful if you only want to make changes to a single Qt module, without compiling the whole Qt framework, i.e. you can clone one of the submodules and use your "existing" qmake on it instead of compiling QtBase (in that case, you skip step 4)
Final notice: When I tried opening the whole Qt-Project, QtCreator crashed on my system because the project was to big to handle. I would recommend you to only open one of the modules within the super repostitory, i.e. "qtbase", "qtdeclarative", etc.
To test the deployment process I am trying to deploy the included demo app Minehunt. I am able to get it to run, no crashing or errors, but the screen is all white.
I believe this generally means that I am missing plugins. Dependency walker reports no problems, and I even tried including ALL the plugins from the Qt MingW plugins directory, but no such luck.
Here is what I am including so far; Can anyone advise what else I need to add to get it to run?
Your dlls don't look bad at all. I think, too, that it's your plugins. Even if they are there, there is a good chance, that your program don't find them. Qt is a bit picky where to look by default. You might try qt.conf. This is a small textfile you must create in the folder where your executable lies. It contains the path to your Qt plugins.
For instance, in one of my projects I have the followin folder layout:
Appfolder
plugin
qt
plugins
imageformats
sqldrivers
myapp.exe
qt.conf
...many dlls...
Then I added a qt.conf file to the Appfolder, which has the following content:
[Paths]
Plugins = plugins/qt/plugins
My program is Qt 4, but I don't think this aspect of plugin deployment changed in Qt5.
All my qt dlls are in qt. And I add the following PATH: SET PATH=.\plugins;.\plugins\qt;%PATH%. Works like a charm on any Windows I ever tried.
Edit:
I then created a .bat file, which does:
SET PATH=.\plugins;.\plugins\qt;%PATH%
cd Appfolder
start myapp
This was an ugly quick fix, which I did not have the time to replace with something better, yet.
If application runs and shows blank screen then that usually indicates two things :
All the dependencies (dlls) are probably present and detected properly.
Most probably whats missing is the presence of qml files at the correct location.
In your main.cpp check the path of qml file which you would have given, and see if relatively that folder is present at the same location corresponding to your executable.
Also, instead of running the executable by double clicking, run it through the command line. It might print some messages if it is not able to locate some images/files/other dependencies etc according to the specified paths.
Edit 1 :
Add this flag in the .pro file :
CONFIG += console
It will give the exact debug message in a console once you run the application.
I've inherited a Qt3/Vs2003 project. Which I think's been badly mangled over the years, e.g. there was a new DEBUG macro added to it that was logging to file... opening the solution in VS and checking the build configurations I found there was no debug config (which I've added by copying the release config?) but it's not stopping at breakpoints (although it was at one point, now no longer playing - note: I do appear to be generating PDBs).
So how well should this integrate?
Should breakpoints, code completion etc work or am I expecting too much?
The only integration I've seen is the opening of a UI with Qt designer when I click on the ui in VS.
more...
it's in CVS, does QT have to be checked out with LF line endings?, this is mangling my VDProj?
Shouldn't the compiler output be put in the Release (or Debug) folder, mine's getting dumped in the same folder as the solution.
I added a debug build config, then added a path to the debug symbols and working directory, tried it again and it worked. All the project options appear to be more or less unset (hence the drop location for the exe etc.)
I used to develop in Visual Studio (2008) but almost completely switched to developing in QtCreator now, mainly due to Code Navigation, refactoring and Code Completion.
I'm using the win32-msvc2008 mkspec. So far I've managed to set up everything except for one thing:
Incremental Linking.
In my project file I added the line:
QMAKE_LFLAGS += /INCREMENTAL
and I get a linker line like
link /LIBPATH:"(...)" /NOLOGO /INCREMENTAL /DEBUG /MANIFEST (...)
However, it always tells me it cannot find the .exe or it was not built completely by the last incremental build, even if I only change a .cpp file, revert the change and save.
I've tried building with and without shadow build, and with nmake or jom, neither combination works.
Has anyone managed to get QtCreator to link incrementally with nmake?
PS: If I import the project file into Visual Studio using the Qt Plugin, incremental linking works perfectly.
Apparently qmake needs to generate the makefiles differently in order to make incremental linking work properly when you are using nmake.
I filed a bug request, if you're interested, here it is: https://bugreports.qt-project.org/browse/QTBUG-22718
In xcode 3 it was possible to configure specific option for building every single file of a project, like for example disabling specific warnings, thumb code generation and so on.
In xcode 4 such feature is not available, or at least not in an intuitive way. This is however supported, at least as a backward compatibility feature, in projects imported from xcode 3.x.
Does anyone knows a way to specify those settings without having to open the project back in older xcode or creating a project for every single file?
Select the project in the navigator, then select the target from the list. Select the Build Phases tab, then expand the Compile Sources phase. The Compiler Flags column is where you specify per-file compiler flags.