I wanted to learn OpenGl with Cpp using QT-Creator but it seems that i didn't linked my GLFW lib right.
I used
sudo apt-get install libglfw3 libglfw3-dev libglfw3-doc
and
sudo apt-get install libglew-dbg libglew-dev libglew1.13
to install them and afterwards, the QT_Creator "showed" me
//GLEW
#include "GL/glew.h"
//GLFW
#include "GLFW/glfw3.h"
so I thought, I could use them, but i got an "undifened reference to ...".
I already looked at this question, but it doesn't seem to work. And I never worked with CMake or qmake before, so i can't see my mistake.
I can provide my enviroment setup notes for you, or you can read it from my sites, But prevent my site url from invalid someday, I rewrite it here.
Install glfw
First. we need to install dependencies on ubuntu
sudo apt-get install xorg-dev
sudo apt-get install libglu1-mesa-dev
Install glew
Then download source package at official
Extract your package and open your terminal, then cd to what your package location which you just extracted.
Do following commnad to install
make extension
make
sudo make install
sudo make clean
Open QT project and set opengl settings
Open a console project in QT
Add following settings in your .pro file anywhere.
LIBS +=-lGLEW -lglfw3 -lGL -lX11 -lXi -lXrandr -lXxf86vm -lXinerama -lXcursor -lrt -lm -pthread
Try a simple test.
#define GLEW_STATIC
#include <GL/glew.h>
#include<GLFW/glfw3.h>
int main(int argc, char *argv[])
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
return 0;
}
Enjoy it
If you have purpose only learn openGL without help library like glfw or glew you can use QOpenglWidget or QOpenglWindow with QOpenglGLFunctions. Qt give wrapper for all openGL functions, however you can use functions from raw opengl. You can not even use QOpenglWindow or QOpengGlWidget. Qt provides a lot of examples, for instance
http://doc.qt.io/qt-5/qtopengl-cube-example.html
http://doc.qt.io/qt-5/qtgui-openglwindow-example.html
I stumbled on the same problem. I followed Tokenyet answer but I also added also -ldl to the end of LIBS in .pro file and it worked.
I have had the same problem, while trying to develop a a console application project using Qt. I fixed the problem using
-lglfw (not -lglfw3)
it seems like lglfw3 (.so or .a file or whatever) does not exist in the Lib folder unless you compile it your self (video)
*More over libglm-dev is needed for projects that include glm header files. So lanch ubuntu software center to install it or lanch
sudo apt-get install libglm-dev
Related
I am trying to add libusb library from https://github.com/libusb/libusb/releases/download/v1.0.22/libusb-1.0.22.7z
to my qt project can anyone help me ,I can't figure out how to add this library to my project
Open terminal:
sudo apt-get install libusb-1.0-0-dev
Edit file.pro:
LIBS += -lusb-1.0
Edit your source fileHeader.h:
#include <libusb-1.0/libusb.h>
I'm trying to use the QtContacts module. I'm using ubuntu artful and qt 5.10
I've tried this:
sudo apt-get install qml-module-qtcontacts
and this:
sudo apt-get install qtdeclarative5-qtcontacts-plugin
I put in the .pro file: QT += androidextras contacts, but I get the message: Project ERROR: Unknown module(s) in QT: contacts
I also tried this answer: How to install a missing Qt module?
But the module doesn't appear in the modules list:
What did I miss?
QtVersion:
I downloaded the qt-unified-linux-x64-3.0.2-online.run in this link: https://www.qt.io/download
I would try fetching from here, and install with configure/make/make install.
Looking at this documentation, it seems that there is a Contacts API, and a Contacts QML plugin.
Looking at the pro file in this example, there is no contact module appended to QT, but a CONFIG entry like this:
CONFIG += mobility
MOBILITY = contacts
I'm new to opencv. I installed it on my computer using cmake following the tutorial in their website.
mkdir Desctop/opencv
cd Desctop/opencv
git clone https://github.com/Itseez/opencv.git
cd opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
And to compile with opencv using cmake, I add the CMakeLists.txt file in the cpp file directory then execute
cd <cpp file directory>
cmake .
make
But now I know more about opencv. I know that I can make GUI windows with it; I can make buttons, scroll bars and many other UI controls.
But I can't use the GUI tools unless I integrated cmake with QT.I'm not sure how should it be, but I thing it would be something like
cmake -D WITH_QT=ON ..
Reference
But the problem is that I've already installed opencv and I don't know how can I change it's configurations to use QT.
I tried to install cmake-gui to change the opencv installation configurations but I didn't find anything for opencv in the program.
My questions
Do I need to re-install opencv or it's possible to change the settings or changing the content of CMakeLists.txt file?
How can I change the configurations of the current opencv installation so it support QT?
would I need to change the CMakeLists.txt file after changing opencv's configurations?
I just started to use Qt today and I don't know if I did something wrong when I installed it but I can't use QFormBuilder.
Linux Xubuntu 64b
what I did:
I clone this repo : git#gitorious.org:qt/qt5.git
init_repository >> ./configure >> make >> sudo make install
I downloaded qt-creator http://qt-project.org/downloads#qt-creator
I created a new project and when I try to include QFormBuilder he tell me that he doesn't know this file.
So, I saw somewhere someone who says that I need to add QT += uitools to the project file, but now when I try to use qmake, I am getting Unknown module(s) in QT: uitools.
Sorry for my english and thank you for your help.
If you get
Project ERROR: Unknown module(s) in QT: designer
you are missing qttools5-dev package.
To add to the answer by #svlasov, on RHEL or CentOS based systems (7.x or 8.x, etc.) you need to install:
yum install qt5-qttools-devel
Depending on the project you are building, you may also need to install qt5-qttools-static.
Have you actually read the documentation?
It writes this at the beginning:
The QFormBuilder class is used to dynamically construct user interfaces from UI files at run-time. More...
Header: #include
qmake: QT += designer
Inherits: QAbstractFormBuilder.
So, just follow that and put this into your qmake project file:
QT += designer
or you can invoke qmake like this:
qmake QT += designer
Of course, you need to make sure that you have the designer installed properly for this. You will need to install a package like libqt5designer5 on your Ubuntu, or if you had installed Qt manually, you will need to install the designer manually as well.
I am not that familiar with Ubuntu. You may need to install some corresponding development package as well. Either way, the point is that the library and headers need to be installed properly on your system which you seem to lack when getting Project ERROR: Unknown module(s) in QT: designer after either of the aforementioned solutions.
Read the documentation, it says to add the designer module to the .pro file:
QT += designer
Installed Qt Creator 2.8 in ArchLinux
Installed qt5-* (* as every related package) using pacman
examples were not available in the repositories so I used the one in the AUR, qt5-examples
examples are installed under /usr/share/doc/qt/examples
qmake-qt5 -query says:
QT_SYSROOT:
QT_INSTALL_PREFIX:/usr
QT_INSTALL_ARCHDATA:/usr/lib/qt
QT_INSTALL_DATA:/usr/share/qt
QT_INSTALL_DOCS:/usr/share/doc/qt
QT_INSTALL_HEADERS:/usr/include/qt
QT_INSTALL_LIBS:/usr/lib
QT_INSTALL_LIBEXECS:/usr/lib/qt/libexec
QT_INSTALL_BINS:/usr/lib/qt/bin
QT_INSTALL_TESTS:/usr/tests
QT_INSTALL_PLUGINS:/usr/lib/qt/plugins
QT_INSTALL_IMPORTS:/usr/lib/qt/imports
QT_INSTALL_QML:/usr/lib/qt/qml
QT_INSTALL_TRANSLATIONS:/usr/share/qt/translations
QT_INSTALL_CONFIGURATION:/etc/xdg
QT_INSTALL_EXAMPLES:/usr/share/doc/qt/examples
QT_INSTALL_DEMOS:/usr/share/doc/qt/examples
QT_HOST_PREFIX:/usr
QT_HOST_DATA:/usr/lib/qt
QT_HOST_BINS:/usr/lib/qt/bin
QT_HOST_LIBS:/usr/lib
QMAKE_SPEC:linux-g++
QMAKE_XSPEC:linux-g++
QMAKE_VERSION:3.0
QT_VERSION:5.1.0
which means examples are in the right place
But they are not shown in Qt Creator!
How can I bring them in qtcreator?
PS: I don't wanna forget about the solution and install SDK.
I know OP asked for archlinux but I faced the same issue with Ubuntu 20.04. To solve it I had to install the following two packages:
sudo apt-get install qtbase5-examples qtbase5-doc-html
This will show the basic widget examples.
Additional examples (e.g. qt quick) can be added by installing them explicitly:
sudo apt install qtquickcontrols2-5-examples
To actually get them displayed in qtcreator I had to install:
sudo apt install qt5-doc qt5-doc-html
Here is the output of echo $(apt-mark showmanual | grep -P '(libqt|qt)')
cmake-qt-gui qt5-default qt5-doc qt5-doc-html qtbase5-dev qtbase5-doc-html qtbase5-examples qtcreator qtquickcontrols2-5-examples
Edit:
Also make sure to install the qml modules you need, for example:
sudo apt install qml-module-qtquick-controls2
QtCreator Examples are added in Official Repository 'Extra'
https://www.archlinux.org/packages/extra/any/qt5-examples/
install it using :-
sudo pacman -S qt5-examples
Navigate to the installation location of the examples and open the .pro project file with qt-creator.
Alternatively if you just want to build and run the example. Navigate to the directory qmake and then make and then simple run the output
Additionally if you strictly require the examples to show in the IDE, try launching with admin privileges as the installation directory of the examples may require admin privileges.
My situation is that qt example folder has no permission to read and execute for non-root users, fixed it and everything OK. In your case:
sudo chmod +rx /usr/share/doc/qt/examples
I am also using archlinux and have had the same problem. Despite not having the examples & demo installed the qmake-qt5 -query is printing a non-existence path.
It seems Qt5 examples are now on AUR(Arch User Repository).
To get the them
Download https://aur.archlinux.org/packages/qt/qt5-examples/qt5-examples.tar.gz
Extract the package maybe with $ tar xzf qt5-examples.tar.gz
cd qt5-examples which contains the PKGBUILD . Then run makepkg .This will download 165MB qt-everywhere-opensource-src-5.2.0.tar.xz
Run pacman -U qt-everywhere-opensource-src-5.2.0.tar.xz
Qtcreator cannot detect the example without its html file.
So, in my case I've already installed qtbase5-examples, but could not able to see examples in qtcreator.
After,
sudo apt-get install qtbase5-doc-html
examples are visible in qtcreator. It was the same with qt5serialport-examples.
sudo apt-get install qt5serialport-examples qtserialport5-doc-html
Have a nice one.
make sure you run the qt-opensource-linux-x86-android-5.4.0.run like this:
$sudo ./qt-opensource-linux-x86-android-5.4.0.run
please do not forget the "sudo"
or you will find that the examples in the qtcreator is missing.