PDA

View Full Version : Can't build a sample project



gpuckett
2nd May 2014, 18:19
I need to develop a desktop application that will only run on Windows based machines. I've been trying to develp the solution in Java and have found it impossible to build the user interface to match my requirements. I think Qt and C++ is the only way to produce what I need. I have had C++ training but that was quite a few years ago. I am hoping to polish up my C++ skills while I am learning Qt and working with sample programs.

I have installed Qt 5.2.1 (MVSC 2010, 32 bit) along with Qt Creator 3.0.1 running on Windows 7 Pro. I have completed several of the Qt tutorials without major problems. Now I am trying to go through more advanced sample projects and have run into some significant issues. I believe it has to do with getting the project set up properly so that QMake can do what it needs to do.

We have a 3rd party C++ product that provides the GIS functionality we need. It was built using MVSC 2010 but I'm not sure which Qt version. It supports Qt and comes with a couple of sample projects. I am trying to get the simple HelloWorld project working in Qt. The Qt Creator project files are being built on the D: drive under D:\QtProjects\Examples for the moment.

The 3rd party product has been installed in the following directory structure:



C:\Program Files (x86)
GIS
GIS Engine 2 SDK
bin
include
GIS
Engine
Controls
Core
DataSets
Operators
** and others **
libs
samples
*** and others ***


There are a couple environment variables that are pertinent. They are:



GIS_ENGINE_INCLUDE = C:\Program Files (x86)\GIS\GIS Engine 2 SDK\include
GIS_ENGINE_LIBS = C:\Program Files (x86)\GIS\GIS Engine 2 SDK\libs


At first when I tried to build the project I was obviously having problems with the spaces in the file names. So I changed the environment variables to:



GIS_ENGINE_INCLUDE = C:\PROGRA~2\GIS\GISENG~1\include
GIS_ENGINE_LIBS = C:\PROGRA~2\GIS\GISENG~1\libs


Now I am past that and getting more difficult problems.

The project file contains:



QT += widgets
TEMPLATE = app
TARGET = HelloWorldQt
INCLUDEPATH += "$(GIS_ENGINE_INCLUDE)"
QMAKE_LIBDIR += "$(GIS_ENGINE_LIBS)"

HEADERS += \
./helloworldqt.h \
$$INCLUDEPATH/GIS/Engine/Controls/QtMapControl.hpp

SOURCES += \
./main.cpp \
./helloworldqt.cpp

FORMS += \
./helloworldqt.ui


There is a custom widget that implements QtMapControl. It is referenced in the helloworldqt.ui file. The details for the widget are:



<customwidget>
<class>GIS::Engine::QtMapControl</class>
<extends>QWidget</extends>
<header>GIS/Engine/Controls/QtMapControl.hpp</header>
<container>1</container>
</customwidget>


When I attempt to build the project I get three duplicate errors in the ui_helloworldqt.h file. I assume this is generated by QtCreator from the user interface built in the Design editor. The error is:

C1083: Cannot open include file: 'GIS/Engine/Controls/QtMapControl.hpp': No such file or directory ui_helloworldqt.h 18

If I look at the generated header file, line 18 contains:

#include "GIS/Engine/Controls/QtMapControl.hpp"

I have tried a bit of everything and have been browsing forums for days. I have had help with the 8.3 file names but nobody seems to be able to provide any hints as to how I can get past the latest issues.

Could someone please help with some suggestions or explanations as to why I am getting these errors?

ChrisW67
3rd May 2014, 06:39
Your INCLUDEPATH is defective because GIS_ENGINE_INCLUDE is being mangled. When you use backslashes in paths in the pro file they must be escaped, i.e. \\. It is generally easier to use forward slashes everywhere and let qmake adjust. Also, quote the strings. So,


GIS_ENGINE_INCLUDE = "C:/Program Files (x86)/GIS/GIS Engine 2 SDK/include"
GIS_ENGINE_LIBS = "C:/Program Files (x86)/GIS/GIS Engine 2 SDK/libs"


QMAKE_LIBDIR is not the way to add other library search paths or libraries to your project. Remove this line and add:


INCLUDEPATH += "$${GIS_ENGINE_INCLUDE}"
LIBS += -L"$${GIS_ENGINE_LIBS}" -lthelibraryname

Search for "Declaring other libraries" in the qmake manual.

Remove line 9 of the pro file above, it should not be required.

I have not tested the quoting for the paths with spaces but I think it should work as is.

gpuckett
3rd May 2014, 16:41
Thank you very, very much. I was able to get the demo working. There were a couple issues I had to resolve. First of all I cannot get it to work without using 8.3 names. It simply doesn't like the full names with spaces. Also Line 9 was required. I received more than 10 link errors when it wasn't there. I added it back and the program worked.

Now the pro file contains:



QT += widgets
TEMPLATE = app
TARGET = HelloWorldQt
INCLUDEPATH += "C:/PROGRA~2/GIS/GISENG~1/include"
LIBPATH += "C:/PROGRA~2/GIS/GISENG~1/libs"
LIBS += -lGEControls
LIBS += -lGEObjects
LIBS += -lGEMaps


HEADERS += \
./helloworldqt.h\
$$INCLUDEPATH/GIS/Engine/Controls/QtMapControl.hpp

SOURCES += \
./main.cpp \
./helloworldqt.cpp

FORMS += \
./helloworldqt.ui


One last question regarding Qt Creator. Every time I change the pro file the old problems remain when I attempt to build the project. I have to physically remove the D:\QT-Projects\Examples\MIS\build-HelloWorldQt-Desktop_Qt_5_2_1_MSVC2010_32bit_OpenGL-Debug directory before I do the build to pick up the changes. I would assume that's not normal and I'm not doing something right. What would that be?

ChrisW67
5th May 2014, 00:17
You should not be modifying LIBPATH directly. Please use the instructions at:
Declaring other libraries

HEADERS controls which files are pre-processed by moc and should only list your project's source files. Line 13 should not be required if your library has been correctly built. That header file was processed by moc while building the library and the compiled results are be in the library.

Line 13 makes little sense in any case; INCLUDEPATH is a list of directories, not a single directory.