How to debug qt project in xcode? - c++

I've got a Qt Creator project that I need to run as root, and which I need to debug. Root debugging is apparently difficult and unreliable in Qt Creator, so I used qmake with -spec macx-xcode to generate an xcode project, hoping to debug in xcode instead.
I had to change C++ standard library to libstdc++ to get it to link, but otherwise it builds and runs fine.
However, no breakpoints are hit and the Debug Navigator says "No Debug Session" while the program is running. Attempting to attach to the process when it's already running just makes xcode say "Finished running $my_app" and does not attach, though the process is still running.
I suspect I'm trying to debug a release build. Can anyone tell me what I need to do with qmake to generate a debuggable xcode project? Or what I need to do in xcode to get debugging working?
I'm new to OSX and Qt, as you may have guessed.
(This is on OS X 10.8.5, XCode 5.1.1, Qt 4.8.6)
EDIT: the command I'm using to get qmake to generate the xcodeproj is: "/opt/Qt-4.8.6/bin/qmake" ~/path_to_proj/qtproj.pro -r -spec macx-xcode CONFIG+=x86_64
EDIT 2: The source Qt Creator project builds debug and release configurations correctly.

Related

CMake: Qt Project to CLion with MSVC 2017

I'm having a project in Qt Creator and I'm trying to port it into CLion but I found myself blocked into some problems. If any of you could help me to port this CMake project I would really appreciate it.
Qt Creator
So, here is my setup for the Qt Creator project first:
Qt: 5.14.2
Compiler: MSVC 2017 64-bits
Also, here are my custom paths and my build environment:
Also, the build (install) time in Qt Creator takes around 20-30minutes.
CLion
Now in terms of CLion and what I've tried here are the following.
and in terms of setting up the CMake:
I've also added the paths into Environment Variables from CLion
But the problem arises when I'm trying to compile the project.
I'm going to install the project via Build -> Install
After that, I need to wait for around 1h or more(even if in Qt Creator is going to take just 20-30min) to a point where the build will fail and I will receive the following error message
MASM : fatal error A1000: cannot open file : 4 [C:\PRJOJECT_NAME\build_clion\components\extern_crashpad\crashpad\util\crashpad_util.vcxproj]
but if I'm searching for that file, it exists in that folder which is specified. But the problem is that I don't understand why the same project if build with Qt Creator is working but not vice versa. Could any of you help me to understand what I'm doing wrong?
It looks like QT Creator is using Ninja as a generator and CLion is using MSVC.
Try -G Ninja in your CLion CMake Options text box. Make sure Ninja is in a path accessible by CMake.

Qt cannot load cocoa plugin

I'm trying to compile and run an application on a MacBook using Qt Creator. There are no issues compiling the project, but when I try and run it, it seems to be unable to load a plugin.
Could not load the Qt platform plugin "cocoa" in "" even though it was found.
The application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
This error occurs both when trying to run the application from Qt Creator or via Finder. It seems to only happen when I use the CMake build system (no issues when using QMake), but my existing project that I need to deploy on MacOS uses CMake.
My steps to reproduce are:
Install a completely clean MacOS (no user data)
Install Xcode 11
Install CMake 3.15
Install Qt 5.13.1 MacOS package
Open QtCreator->New Project->Qt Quick Application - Scroll
Set build system to CMake (important)
Compile and notice error
I am using:
Qt 5.13.1
macOS Catalina 10.15
Apple Clang 11
I recognize that for final user deployment I will need to use the macqtdeploy tool to copy the Qt libraries to the executable folder, but I should be able to run my app from QtCreator without doing this? Especially as it works fine when using QMake.
So it ended up being some kind of name resolution thing where Qt Creator couldn't decide whether to use the debug or release versions of the framework. Supplying DYLD_IMAGE_SUFFIX=_debug fixed this (add this to the environment section under Kits).

Qt Creator Compiling Error at step 'make'

I just started using Qt Creator for creating C++ GUI programs. I just downloaded it and installed it, but the compiling process is throwing me errors. When I try to compile my project (very simple, just a QLabel on the screen...it's my first project) it comes up with the error:
qtcreator_ctrlc_stub: Command line failed:
C:\Users\andrew\Dropbox\Programming\C++\build-
FirstGUIApp-Desktop_Qt_5_1_1_MSVC2012_32bit-Debug\Makefile 10:04:35:
The process
"C:\Users\andrew\Dropbox\Programming\C++\build-FirstGUIApp-Desktop_Qt_5_1_1_MSVC2012_32bit-Debug\Makefile"
exited with code -1. Error while building/deploying project
FirstGUIApp (kit: Desktop Qt 5.1.1 MSVC2012 32bit) When executing step
'Make'
I hunted around for an answer here and here and a couple other places but I'm just confused about the whole thing. I have a couple of ideas of my own but I don't know how to try my ideas. Here are some of my ideas:
1) MinGW isn't in the path or isn't installed
But, if it isn't in the path, how do I put it in? Where is it? I have Code Blocks installed which has MinGW installed, so could I maybe use it from there?
2) the make file is messed up somehow
Again, what could be wrong and how could I fix it?
3) Qt Creator isn't installed correctly.
Obviously, re-install it, but I want to make sure all other options are tried before, because it took me a very long time to download.
I apologize if I'm sounding noobish or it's a stupid question, but I really am confused with all of this. Please be patient with me and try to explain things well and thoroughly. I'm using Windows 8.1 and downloaded the offline installer. Thanks in advance.
UPDATE
Here is a screenshot of my Qt, how can I tell if it is the visual studio or minGW version?
UPDATE
Here is my MinGW Folder in CodeBlocks. Is this the folder with the compiler or is it something else?
For your ideas:
1: if you downloaded from qtproject with binary. then qt and qt creator should be installed under the C:\Qt\Qt5.1.1 then corresponding minGW should be stay in C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\gcc.exe
this is the directory you need. Remember, QtCreator needs two tools to make sure your project and compile and run, qmake and compiler.
Qmake is tool help you translate .pro file into makefile,
compiler (gcc) minGW use gcc to run the makefile, compile your code to binary.
where to figure out tools you are using are correct?
---> qtcreator --> Tools -> Build&Run -> Kits
in here You should be able find different kits, of course you maybe have only one.
Select one, Double check the Qt Version and Compiler is the one you wish to use.
click Manage next to compiler, Every compiler in the Auto-detect should be ok to use.
If you don't see anyone, add one, click Add, MinGW, put C:\Qt\Qt5.1.1\Tools\mingw48_32\bin\gcc.exe like into path. ABI should auto-set depends on your environment.
Answer to your second question, what's wrong with your makefile, no one knows, you should check your .pro, usually makefile are generated by qmake xx.pro. Double check your .pro file and re-run qmake will solve the problem.
in tools->options->build&run check if minGW is actually there in the compiler and kit list
in the project tab (on the left hand side) you can set the environment for the build click the PATH value and add the path to minGW to it (you may need to add a lib and include var so the standard library gets added)
re run qmake from the build menu
double check you have the correct version it looks like you have the visual studio Qt not the minGW version,
Terminal:(in Linux)
sudo apt-get install build-essential cmake libqt4-dev
i'm sorry i dont know why this code works,but i have the same problem in linux and this code worked.

Can't build, qmake.exe crashes in Qt Creator

I'm using Qt Creator on Windows XP SP3. I want to develop C++ desktop applications.
I made a new project. Everytime I click build, it appears a window which says:
qmake.exe has encountered a problem and needs to close. We are sorry for the inconvenience.
In Qt Creator, something similar to this appears:
20:36:55: Running build steps for project yyy...
20:36:55: Starting: "d:\qtsdk\desktop\qt\4.8.1\mingw\bin\qmake.exe" D:\...\yyy.pro -r -spec win32-g++ "CONFIG+=declarative_debug"
20:38:00: The process "d:\qtsdk\desktop\qt\4.8.1\mingw\bin\qmake.exe" crashed.
Error while building project yyy (target: Desktop)
When executing build step 'qmake'
I can't build, I have reinstalled the software but it keeps giving the same error.
Can you give me any idea of what is happening?
Running the qmake command from the command line via a bat file works.

Get Qt running on Mac OS X Mountain Lion

I wanted to set up Qt so I could develop applications with it. It all seemed pretty straight forward - i ran the installer and it installed. I then added the path variable to /etc/profile. the qmake -v command works as described in the netbeans docs, but netbeans does not seem to detect the include files required for Qt.
Yup I fixed it:
If you are getting those errors, add the qmake command to your path variable, reboot your computer and then attempt to run the basic QT project in netbeans. It should prompt for a qmake directory. Point that towards QT's bin folder and the project should run. For the the squiggly lines disappeared after a project cleanup.