Running QMake and Eclipse integration
-
Hello all,
I am currently working on integrating Qt with Eclipse. I have it mostly working however, there are a few issues. I have created a small test program to test my Qt integration with eclipse. I can post additional details about my make file and the source.
Currently, I have it setup in eclipse such that qmake is ran as an external tool. I press a button and qmake is ran to create a .pro file and a make file.
i switch my eclipse settings to work with an external makefile (the one that QMake creates). However, I am getting compile errors stating that it can't find a reference to QApplication. This is quite odd.
I opened my generated pro file and this is what is in it:
###################################################################### # Automatically generated by qmake (3.1) Thu May 14 23:20:06 2020 ###################################################################### TEMPLATE = app TARGET = QTTest3 INCLUDEPATH += . # The following define makes your compiler warn you if you use any # feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 # Input HEADERS += MainFrame.h SOURCES += main.cpp MainFrame.cpp MenuFile.cpp
So, it looks like qmake is now adding in the directories for my includes!
In eclipse, I have this all set up. I have my include directories pointing to the correct include folders for Qt. In fact, intellisense works and I am able to compile the program using eclipse's built-in compiler. However, I am unable to link it because I get an issue related to the VTable. So I need to use QMake and the Makefile to build my MOC files.
Anyways, back to my question, how can I get QMake to include the include directories and my library paths?
-
Any thoughts?
-
Ok, so I looked more closely at the make file that qmake creates and it looks like that it is missing some include directories. Mainly the directory fro QtWidegts:
############################################################################# # Makefile for building: QTTest3 # Generated by qmake (3.1) (Qt 5.11.0) # Project: QTTest3.pro # Template: app # Command: /home/name/Qt5.11.0/5.11.0/gcc_64/bin/qmake -o Makefile QTTest3.pro ############################################################################# MAKEFILE = Makefile ####### Compiler, tools and options CC = gcc CXX = g++ DEFINES = -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES) CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES) INCPATH = -I. -I. -I../../Qt5.11.0/5.11.0/gcc_64/include -I../../Qt5.11.0/5.11.0/gcc_64/include/QtGui -I../../Qt5.11.0/5.11.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I../../Qt5.11.0/5.11.0/gcc_64/mkspecs/linux-g++ QMAKE = /home/name/Qt5.11.0/5.11.0/gcc_64/bin/qmake DEL_FILE = rm -f CHK_DIR_EXISTS= test -d MKDIR = mkdir -p COPY = cp -f COPY_FILE = cp -f COPY_DIR = cp -f -R INSTALL_FILE = install -m 644 -p INSTALL_PROGRAM = install -m 755 -p INSTALL_DIR = cp -f -R QINSTALL = /home/name/Qt5.11.0/5.11.0/gcc_64/bin/qmake -install qinstall QINSTALL_PROGRAM = /home/name/Qt5.11.0/5.11.0/gcc_64/bin/qmake -install qinstall -exe DEL_FILE = rm -f SYMLINK = ln -f -s DEL_DIR = rmdir MOVE = mv -f TAR = tar -cf COMPRESS = gzip -9f DISTNAME = QTTest31.0.0 DISTDIR = /home/name/eclipse-workspace/QTTest3/.tmp/QTTest31.0.0 LINK = g++ LFLAGS = -Wl,-O1 -Wl,-rpath,/home/name/Qt5.11.0/5.11.0/gcc_64/lib LIBS = $(SUBLIBS) -L/home/name/Qt5.11.0/5.11.0/gcc_64/lib -lQt5Gui -lQt5Core -lGL -lpthread AR = ar cqs RANLIB = SED = sed STRIP = strip
Any thoughts on how I can add those directories? Of course I can simply type it in but is there a way that I can fix qmake or fix my settings so that qmake can add the paths correctly to the include directory?
-
Ok another update:
The makefile is in fact missing the references to the include path and the libraries. If you look closely at what I have posted above, the include directory is missing the path for the Qt5Widgets and the corresponding library.
I can I edit my my setting for qmake to include these paths when it generates a makefile?
-
Should I post this in another subforum????????
I think that this questions should be a simplier one:
I am attempting to have qmake perform a shadow build on my project so that all of my .o and moc files are in a serperate directory to keep my source directory clean.
I have attempted to run qmake (This was recommended from a stackoverflow) as:
qmake ./Build
However, I get an error stating that it is a directory and not a file.
My question is this: What is the proper way to run qmake from terminal to build a project as a shadow build?
-
Ok, so, after many hours, I think that I got most of it working with the shadow build in eclipse. This is to serve as documentation for myself and if anyone else comes by with the same issue.
- First, you need to create 3 external tools. All three will be referencing the location of qmake. So find that first. Again, there will be 3 external tools that we create with slightly different settings, their names will be qmake, QMake (.pro file), QMake (makefile)
qmake:
a) For this, set location to the location of qmake.
b) Working directory will be the top level source directory
c) Under the refresh tab, you want to refresh the specific resource which is this project. Check the Recursively include sub-folders options
d) under the Build tab, you want to build the specific project you are working with and to include referenced projects
e) Under Common tab, in the Display in favourites menu check external toolsQMake (.pro file)
a) Set location of qmake
b) Set the working directory to be the top level (I think it is fine if the .pro file is in the same folder as source)
c) Under arguments set-project
d) Now for the liraries that you what to use in your QT Application you will need to specify them after the project arguement. For example, in a project, I want to use QApplication which is apart of the QWidgets library. To add this as an include path and to the linker libraries, I would change the arguments to look like-project "QT+=widgets"
e) Uncheck the Refresh resources upon completion
f) Uncheck build before launch
g) Do same as e aboveQMake (makefile)
a) Set location of qmake
b) Set the working directory to be the location that you want your build files to be located in
c) Set the arguments to be/location/to/.pro/file.pro -r
d) Uncheck the Refresh resources upon completion
e) Uncheck build before launch
f) Do same as e in qmake heading-
Now that we have our external tools configured, we will need to edit the build settings. Right click on the project in the Project Viewer of eclipse and go to Properties. Click on C/C++ Build option and go to the Builder Settings tab.
2a) Uncheck the Generate Makefiles automatically.
2b) Under Build Location, set the path to be the location of where you want your build files to be located.
2c) At this time, I have everything left as default. Although, I will probably change the Build Command to be something that will allow me to parallel build. -
I am not sure if this is required, but I would recommend to set up your include paths and libraries under the C/C++ General->Paths and Symbols. I am not sure if this step is necessary but it is at least good practice.
-
Now, we need to change the directory of the C/C++ Application. To do this, click the down arrow that is next to the run button in your tool bar. A window should come up with your project already ready to go. Under C/C++Application, change the folder location to be the location that you set your build directory.
Now that we have everything set up, the procedure to run everything is as follows:
- Create your .pro file
- Create the makefile
- Right-click on the project in the project viewer and click build (or clean if you want to do a clean build)
- Click on run
Note: There might be an additional step in there. Like for me I need to edit the makefile because it forgets to add in some libraries. I am still working on this issue.
Well, I hope that this post was informative to some people here on the forum. Happy coding.
Edit:
Added in step on how to include QT libraries to qmake to be included in the .pro file
-
Ok, so I think that I kinda figured out why the makefile misses the libraries.
In the .pro file, I need to specify
QT += widgets
.After exploring more, I found out that if you run this command:
qmake -project "QT+=widgets"
This will automatically add the widgets include and the library path to the makefile. Which when I do a clean build, can compile the project successfully. The project will also run successfully also.
-
Evaluation
Hey guys, just looking for some feedback on this. So no one in the community responded to the post. Not that anyone is obligated to responding, but I think that this process would have been better if I got some feedback early on.
So, I am looking to improve my posting and I have a couple of questions for you guys on how I can improve my posting
-
Did I post in the wrong sub-forum? I choose tools because I felt that qmake was a tool that is used for Qt. Was I incorrect in this logic?
-
I posted this question in Qt (even though I was building with eclipse) because I got some flak from the eclipse forums stating that I was posting off topic and that I should post in the Qt forum.
-
Did I post not enough information?
-
Was the question on or off topic?
Please let me know and I look forward to seeing your constructive feedback!
-
-
Hi,
No worries, the sub forum is correct.
I rather wonder why the eclipse forum folks think that it's off-topic to ask a question about using their IDE for C++ development with a framework like Qt.
As for the lack of answer to your question: I would say it's likely because nobody currently active here uses eclipse for Qt related development.
-
Hi,
No worries, the sub forum is correct.
I rather wonder why the eclipse forum folks think that it's off-topic to ask a question about using their IDE for C++ development with a framework like Qt.
As for the lack of answer to your question: I would say it's likely because nobody currently active here uses eclipse for Qt related development.
Thank you for your reply. That seems pretty reasonable. I think that this is in a grey area where it cam be either or.
On one hand, yes it is an eclipse issue because I am setting up eclipse settings. But at the same time you can probably make a valid argument on it being Qt because I am also verifying QMake and make settings.
Well, I hope that my post will help someone else in the future
-
You could even make a Wiki entry out of it or a blog article.
That way, it might even be easier to find.