Results 1 to 4 of 4

Thread: Can't build a sample project

  1. #1
    Join Date
    May 2014
    Posts
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default Can't build a sample project

    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:

    Qt Code:
    1. C:\Program Files (x86)
    2. GIS
    3. GIS Engine 2 SDK
    4. bin
    5. include
    6. GIS
    7. Engine
    8. Controls
    9. Core
    10. DataSets
    11. Operators
    12. ** and others **
    13. libs
    14. samples
    15. *** and others ***
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. GIS_ENGINE_INCLUDE = C:\Program Files (x86)\GIS\GIS Engine 2 SDK\include
    2. GIS_ENGINE_LIBS = C:\Program Files (x86)\GIS\GIS Engine 2 SDK\libs
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. GIS_ENGINE_INCLUDE = C:\PROGRA~2\GIS\GISENG~1\include
    2. GIS_ENGINE_LIBS = C:\PROGRA~2\GIS\GISENG~1\libs
    To copy to clipboard, switch view to plain text mode 

    Now I am past that and getting more difficult problems.

    The project file contains:

    Qt Code:
    1. QT += widgets
    2. TEMPLATE = app
    3. TARGET = HelloWorldQt
    4. INCLUDEPATH += "$(GIS_ENGINE_INCLUDE)"
    5. QMAKE_LIBDIR += "$(GIS_ENGINE_LIBS)"
    6.  
    7. HEADERS += \
    8. ./helloworldqt.h \
    9. $$INCLUDEPATH/GIS/Engine/Controls/QtMapControl.hpp
    10.  
    11. SOURCES += \
    12. ./main.cpp \
    13. ./helloworldqt.cpp
    14.  
    15. FORMS += \
    16. ./helloworldqt.ui
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. <customwidget>
    2. <class>GIS::Engine::QtMapControl</class>
    3. <extends>QWidget</extends>
    4. <header>GIS/Engine/Controls/QtMapControl.hpp</header>
    5. <container>1</container>
    6. </customwidget>
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,668
    Thanks
    13
    Thanked 1,595 Times in 1,523 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can't build a sample project

    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,
    Qt Code:
    1. GIS_ENGINE_INCLUDE = "C:/Program Files (x86)/GIS/GIS Engine 2 SDK/include"
    2. GIS_ENGINE_LIBS = "C:/Program Files (x86)/GIS/GIS Engine 2 SDK/libs"
    To copy to clipboard, switch view to plain text mode 

    QMAKE_LIBDIR is not the way to add other library search paths or libraries to your project. Remove this line and add:
    Qt Code:
    1. INCLUDEPATH += "$${GIS_ENGINE_INCLUDE}"
    2. LIBS += -L"$${GIS_ENGINE_LIBS}" -lthelibraryname
    To copy to clipboard, switch view to plain text mode 
    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.

  3. #3
    Join Date
    May 2014
    Posts
    13
    Qt products
    Qt5
    Platforms
    Windows

    Thumbs up Re: Can't build a sample project

    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 Code:
    1. QT += widgets
    2. TEMPLATE = app
    3. TARGET = HelloWorldQt
    4. INCLUDEPATH += "C:/PROGRA~2/GIS/GISENG~1/include"
    5. LIBPATH += "C:/PROGRA~2/GIS/GISENG~1/libs"
    6. LIBS += -lGEControls
    7. LIBS += -lGEObjects
    8. LIBS += -lGEMaps
    9.  
    10.  
    11. HEADERS += \
    12. ./helloworldqt.h\
    13. $$INCLUDEPATH/GIS/Engine/Controls/QtMapControl.hpp
    14.  
    15. SOURCES += \
    16. ./main.cpp \
    17. ./helloworldqt.cpp
    18.  
    19. FORMS += \
    20. ./helloworldqt.ui
    To copy to clipboard, switch view to plain text mode 

    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?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,668
    Thanks
    13
    Thanked 1,595 Times in 1,523 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can't build a sample project

    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.

Similar Threads

  1. Error on try to build a project example.
    By radialdeveloper in forum Newbie
    Replies: 1
    Last Post: 25th May 2013, 22:38
  2. Sample project ( QT_4.7 + OPENCV_2.3 )
    By andre_teprom in forum Newbie
    Replies: 1
    Last Post: 27th July 2011, 05:17
  3. Sample project ( QT4 + OpenCV) --> Request
    By andre_teprom in forum Newbie
    Replies: 12
    Last Post: 26th July 2011, 06:40
  4. Nonstop when build project
    By Wong in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2011, 12:39
  5. Cant build Qt project
    By ChrisBuchholz in forum Installation and Deployment
    Replies: 7
    Last Post: 20th July 2010, 23:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.