2

I have been given a C++/C code with a .pro file to compile in Qt (it is a large, messy code, so I would like to use Qt and the .pro file provided).

The code is intended to generate a GUI. I can compile it in Qt without any errors (on both Mac OS X 10.7.5 and Mac OS X 10.8), and I see the executable. However, when I click on it, nothing happens. When I run it the usual way via the command line nothing happens. Here are the run commands I'm trying:

./calc.app/Contents/MacOS/calc

exec ./calc.app/Contents/MacOS/calc (this one results in the output: [Process completed]).

In the .pro file (below), I do not see anything that seems to indicate I want a GUI. However, I read at the Qt help site that the GUI module does not need to be specified in the .pro file because it is included automatically. Perhaps I am misunderstanding something?

Are the any issues with my .pro file?

TEMPLATE = app
LANGUAGE = C++
TARGET = calc
VERSION = 3.1.0

CONFIG -= qt
CONFIG += warn_on
CONFIG += debug
#CONFIG += windows
CONFIG += console

DEFINES += IPMGEMPLUGIN
DEFINES += NOPARTICLEARRAY

!win32 {
  DEFINES += __unix
}

GMS_CPP = ../GMS
GMS_H   = $$GMS_CPP

DEPENDPATH +=
DEPENDPATH += .
DEPENDPATH += $$GMS_H

INCLUDEPATH +=
INCLUDEPATH += .
INCLUDEPATH += $$GMS_H

QMAKE_LFLAGS +=
OBJECTS_DIR = obj

SOURCES      +=   main.cpp

include($$GMS_CPP/gms.pri)
tshepang
  • 12,111
  • 21
  • 91
  • 136
Ant
  • 753
  • 1
  • 9
  • 24
  • 2
    What does "compile in QT" mean? – JBentley Jan 11 '14 at 17:41
  • Try with `macx:CONFIG -= app_bundle` and run the resulting binary on a console. That should make sure you see all output, just in case it's a CLI/non-GUI program (the .pro file somewhat suggests that, but one cannot be sure without seeing the code) – Frank Osterfeld Jan 11 '14 at 17:41
  • @FrankOsterfeld Thanks for your suggestion. I tried it. The only output I see is /Users/me/Developer/trunk/standalone/GMS/trunk/build-calc-Qt_4_7_4_gcc-Debug/gmcalc ; exit; logout – Ant Jan 11 '14 at 17:54
  • 7
    This question is [being discussed](http://meta.stackexchange.com/questions/215808/power-mad-moderators) at meta @LaszloPapp – Rob W Jan 11 '14 at 18:35
  • 2
    I cannot reproduce this. The content of `$$GMS_CPP/gms.pri` and a minimal source file is necessary IMHO. – László Papp Jan 11 '14 at 19:21
  • What does `dtruss` give you? See e.g. http://stackoverflow.com/q/1925978/318716 or http://stackoverflow.com/q/1258481/318716 – Joseph Quinsey Jan 11 '14 at 20:42
  • In the project (.pro) file, `CONFIG -= qt` tells us this is a non-QT application; it will not be linked against the Qt libraries. `CONFIG += console` suggests that it is a console application, and is not intended to have a GUI. – Casey Jan 11 '14 at 22:36

2 Answers2

5

I don't know anything about Qt, and of course none of us know anything about the specific application you're compiling - so the assistance I can give you may be woefully inaccurate.

However, this sticks out like a sore thumb:

#CONFIG += windows
CONFIG += console

A quick Google search indicates that Qt does indeed support console applications - that is, applications which do not create a GUI, but instead act as console / terminal / command-line tools. This appears to be the case with the one you're working with. Presuming the application even works, it likely expects input to be passed to it on the command line, and will produce output of some sort in response - but with this configuration, it will not create a GUI.

I recommend contacting the person who gave you this application for further support.

László Papp
  • 51,870
  • 39
  • 111
  • 135
Shog9
  • 156,901
  • 35
  • 231
  • 235
  • 1
    That option only exists for Windows, so it is irrelevant for Mac. It is a no-op on Mac. Also, please take a look at the qt tagwiki. It discourages the usage of "QT" as QT is Quick Time (different project and brand). – László Papp Jan 11 '14 at 18:57
  • 2
    You're rather missing the point, Laszlo. If the application was not written to create a GUI, then it isn't going to magically gain one by being compiled on a different OS from the one on which it was written. If you have more extensive knowledge of this topic, consider writing your own answer - as I noted straight away, I have no experience here beyond an ability to observe what is in front of my nose. – Shog9 Jan 11 '14 at 19:02
  • I am afraid I cannot write an answer without seeing the source code and the .pri file as requested. It is unlikely though IMO that the OP wants to run a GUI application and he does not even have a GUI application. I mean, that would be a strange mistake to make, wouldn't it? :) That is my last resort to assume. I think this line is just the bad result of a copy/paste, but then again, I will not post an answer until I am sure, but for that I would need to see more. – László Papp Jan 11 '14 at 19:24
  • Actually, @Laszlo, I strongly suspect that this is not even a programming question - if this wasn't being actively discussed on MSO right now, I would've already migrated it. Imagine downloading an application off the 'Net, one you've never seen before, and compiling it... There's no documentation, and at best a functional description to go with it... How do you know what sort of UI this application will present? You may *assume* that it's a GUI because that's kinda Qt's *forte* - but there's no requirement that this actually be true (and the listing in the question strongly implies it's not). – Shog9 Jan 11 '14 at 19:32
  • Shog9, I believe the OP is trying to take over the codebase, and there might be some programming mistake. I agree that however, this is off-topic as it stands. Not only the source code is not shown, but not even the .pri build system include file. OT: As per Qt's forte: Qt is an application framework, not GUI framework anymore as initially launched. Although, I can somewhat understand people's confusion about that. – László Papp Jan 11 '14 at 19:35
1

CONFIG -= qt basically means "The target is [not] a Qt application/library and [does not require] the Qt library and header files." You should delete that line. Source: http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#config

Also, it couldn't hurt to add QT += core gui. This is normally done for you automatically, but since you're having project file problems it couldn't hurt... Also, make sure your main.cpp's main method ends in return a.exec();, and that a is a QApplication instance (Qt 4.x) or a QGUIApplication instance (Qt 5.x). main.cpp should be a short function that creates the main widget or window, shows it, then starts the event loop.

If your project still doesn't work properly, I would highly recommend that you ditch the project file. In other words, I would download the OS X package for the Qt SDK, create a new project, then import your files into the new project. After that, I would pluck only the necessary lines from your old .pro file and put them in the new one until it works (specifically, I noticed you have some custom DEFINES += ...). However, all of this advice assumes the fault lies in the project file, not your code. ;-)

cbh2000
  • 2,183
  • 21
  • 17
  • Yes, `CONFIG -= qt` is also a proof for that what the OP posted is in contradiction IMHO. It should give a compilation error, so that had to be removed before even trying to get the application built. – László Papp Jan 11 '14 at 20:50