PDA

View Full Version : Error creating new project in c + +



uzumaki0160
25th August 2012, 20:05
8148

Arguments ?

Generator ?

help

using win7 64bits

ZikO
25th August 2012, 21:25
Is there any particular reason why you want to use cmake instead of qmake?

Usually, Qt works this way. You start with <your application name>.pro where you put information about your headers, source files, sql, translations etc. For instance:


HEADERS += \
header1.h \
header2.h \
class1.h
class2.h
class3.h

SOURCES += \
main_source_file_with_main.cpp \
source_for_class1.cpp \
source_for_class2.cpp \
source_for_class3.cpp \

OTHER_FILES += \
any_file_that_may_be_needed_by_your_application.tx t

RC_FILE += resource_file_eg_your_icon.rc

TRANSLATIONS += tranlsation_to_yuor_other_languages.ts

QT += sql

Then, you run

qmake <your application name>.pro
which creates for you a Makefile in the application folder along with two other folders: debug and release (in Windows). You can then execute "make" without any argument (mingw32-make or nmake in windows and I think make in MAC OS X whichever compiler you want to use) and have an application ready to use. The default is to compile a debug version. You may also want to compile a "release" version by using "make release". In MAC OS X, the procedure is almost the same. However, there are slight system dependent tricks, for instance when you want to have an icon. The solution about works only in Windows system. In MAC OS X, it has to be done in different way.

uzumaki0160
25th August 2012, 22:57
I think you got it wrong. I'll put the steps I follow to create the application and then the error.

First I go to File> New file or Project> non-qtProject> Plain C + + project (CMake build)> then choose ... next screen ...

I put the project name and location, then I click next.

and this screen appears >> 8149

after I click finish.

and this screen appears >>8149

I click next and it appears that first screen

ChrisW67
25th August 2012, 23:50
You need to tell CMake which toolchain you have installed so that it can look for and use it to build your project.
http://www.cmake.org/cmake/help/cmake-2.6.html#section_Generators

Your first screen shot shows a drop down asking for this information: it is the equivalent of the -G option to the cmake command line utility. If I recall correctly CMake looks for Visual Studio and uses that by default if present. It does not look for other possibilities and needs to be told of them.

uzumaki0160
26th August 2012, 00:16
so I have to have installed visual studio? only that?

ChrisW67
26th August 2012, 05:26
In order to use CMake you need CMake installed; is is not part of Qt.
In order to use Qt you need a C++ compiler; this is also not part of Qt (although the Qt SDK can install the MingW compiler and tools for you). You can use the full Microsoft Visual Studio, the Microsoft Window SDK (that includes a C++ compiler) or the MingW (GCC) tools: up to you. Whichever tools you you choose to use CMake needs to know about them in order to generate build commands using them. CMake makes a guess and uses the Microsoft tools if it finds them, otherwise you need to tell it what tools to use.

ZikO
26th August 2012, 20:46
If I may ask this question here, what is the difference between Qmake and CMake?

ChrisW67
26th August 2012, 22:55
qmake is part of the Qt library's supporting tools. It is used to generate platform/environment specific build instructions for a project from a project description (*.pro) that is (mostly) platform independent. The build instructions are typically output as a Makefile for a make utility.

CMake (http://www.cmake.org/) is a third-party tool that provides a similar cross-platform build capability. Given a project description in CMakeLists.txt CMake will generate Makefiles (generally) matching the specified target tool set that can be used to build the project. KDE is a user of CMake.

I think Qt beginners should start with qmake.

ZikO
28th August 2012, 12:00
Thanks Chris,

Thanks to the link you have provided, I understood what CMake does and how powerful it can be. Of course, at my level of advance I am going to rely on QMake due to small projects I do but I remember CMake was mentioned in one of the video tutorials even for beginners and a lecturer clearly stated that QMake may not be the best option for larger projects. I was simply wondering when one of each is used over the other. Anyway, thanks for the answer.