How to manually set GCC as the compiler in QtCreator? - qt

I installed QtCreator on an Odroid but it seems to be missing a compiler. I tried the following terminal commands but it did not solve the problem.
sudo apt-get install g++
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
How can set GCC as the compiler in QtCreator ? Thanks in advance.

Define a compiler in Tools>Options>Build & Run>Compilers, then switch to the kits tab and add that compiler to the kit you want to use.
The process is described in detail in the manual:
https://doc.qt.io/qtcreator/creator-tool-chains.html for the compiler setup and https://doc.qt.io/qtcreator/creator-targets.html is about the kits.

Related

Can't build project on Ubuntu using QT6.4 and CMake

I installed a fresh new copy of QTCreator on a Ubuntu VM. It is a clean virtual machine. Then I create a dummy QTQuick project with almost nothing in it. But creator fails to compile, saying CMAKE_CXX_COMPILER not found. See message below:
error: No CMAKE_CXX_COMPILER could be found. Tell CMake where to find the compiler by
setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER
to the full path to the compiler, or to the compiler name if it is in the PATH.
Am I missing the compiler? This is a fresh install and I don't understand. Creator is showing the only compiler option. See the screen shot below:
Any ideas why it does not compile from a clean install, using all default option? The compiler must be there.
thank you.
I followed these instructions and it worked finally.
sudo apt-get update && sudo apt-get upgrade
sudo apt-get -y install build-essential openssl libssl-dev libssl1.0 libgl1-mesa-dev libqt5x11extras5
downloaded the install and made it executable
chmod +x qt*.run
then it worked.
Here is the page with more explanations:
https://web.stanford.edu/dept/cs_edu/resources/qt/install-linux

Build project in Qt Creator using CMake from snap

Ubuntu 20.04
I just want to use default snap and apt versions
Qt Creator 4.11.0 from apt:
sudo apt install qtcreator qt5-default
CMake 3.24.0 from snap:
sudo snap install cmake --classic
If I open the project, it gives an error:
Running /usr/bin/snap /home/fresh/Downloads/test -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++ -DCMAKE_C_COMPILER:STRING=/usr/bin/gcc -DCMAKE_PREFIX_PATH:STRING=/usr -DQT_QMAKE_EXECUTABLE:STRING=/usr/bin/qmake in /tmp/QtCreator-BsxNPO/qtc-cmake-BcKQdVpk.
error: unknown command "/home/fresh/Downloads/test", see 'snap help'.
CMake process exited with exit code 64.
Any change to make it work properly without building CMake from source or installing newer version of Qt Creator?
Solution:
sudo ln -s /snap/cmake/current/bin/cmake /usr/bin/cmake
sudo ln -s /snap/cmake/current/bin/ccmake /usr/bin/ccmake
sudo ln -s /snap/cmake/current/bin/cpack /usr/bin/cpack
In Qt go to Tools > Options > Kits > CMake in Manual set Path:
/usr/bin/cmake
Go back to Kits tab, in CMake Tool choose added new CMake
Relaunch Qt. It works

Qt 5.12: Failed to find "GL/gl.h" in "/usr/include/libdrm"

I have a freshly installed Ubuntu 18.04.3 system (NVIDIA) with only Qt SDK 5.12.5, build-essential, git, and CMake installed. I'm trying to build a Qt project by opening the main CMakeLists.txt in Qt Creator:
Check for working CXX compiler: /usr/bin/g++
Check for working CXX compiler: /usr/bin/g++ -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at /home/juzzlin/Qt/5.12.5/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message):
Failed to find "GL/gl.h" in "/usr/include/libdrm".
Call Stack (most recent call first):
/home/juzzlin/Qt/5.12.5/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:174 (include)
/home/juzzlin/Qt/5.12.5/gcc_64/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:89 (find_package)
CMakeLists.txt:89 (find_package)
What should I still install?
Note: I haven't installed Qt from repositories at all. Only via the official online installer.
You need mesa packages.
mesa-common-dev
libglu1-mesa-dev
$ sudo apt install mesa-common-dev libglu1-mesa-dev
And Try.
If anybody using Fedora/RHEL finds this question, mesa packages are named differently here.
mesa-libGL
mesa-libGL-devel
$ sudo dnf install mesa-libGL mesa-libGL-devel
Source: https://access.redhat.com/solutions/56301
In OpenSuse Leap mesa packages are named differently too.
Use:
sudo zypper install Mesa-libGL-devel
to solve it.
I tried it with OpenSuse Leap 15.2 and 15.3.
For centos 7
sudo yum install libGL-devel

Compiling Qt 4.8.3 on Ubuntu 12 failing

I am new to Ubuntu and i am getting a message while building Qt 4.8.3 on Ubuntu 12:
Basic XLib functionality test failed! You might need to modify the
include and library search paths by editing QMAKE_INCDIR_X11 and
QMAKE_LIBDIR_X11 in
/home/majidmax/qt-everywhere-opensource-src-4.8.3/mkspecs/linux-g++.
what the proper steps to build Qt on Ubuntu?
http://qt-project.org/doc/qt-4.8/requirements-x11.html
the website provide the package list which must be installed
try it~
These are the packages you need to install and you'll be good to go. I just had this same problem and this worked for me. These came from the link provided by Garlic Tseng in the accepted answer. I am just putting these here for convenience:
libfontconfig1-dev
libfreetype6-dev
libx11-dev
libxcursor-dev
libxext-dev
libxfixes-dev
libxft-dev
libxi-dev
libxrandr-dev
libxrender-dev
One (copy pastable) command to install all:
sudo apt-get install libfontconfig1-dev libfreetype6-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxrandr-dev libxrender-dev
What about sudo apt-get build-dep qt4-qmake?
Try to run that command before you compile Qt (on Debian-like distros).
Same problem i faced in fedora20 (64-bit) for Qt-4.8.3
1)- yum install libXext-devel
(internet connectivity should be there for checking the dependency and install all dependency).
2)- ./configure
3)- make
4)- make install
5)- Installation finish successfully.
The error message doesn't give a lot of information as to the actual issue of XLib failing.
To get more information on the error causing it to fail you can 'make' the xlib tests:
$ cd <Qt_Source_Directory>/config.tests/x11/xlib/
$ make
g++ -Wl,-O1 -o xlib xlib.o -L/usr/X11R6/lib -ltcg -lXext -lX11 -lm
/usr/bin/ld: cannot find -ltcg
collect2: error: ld returned 1 exit status
make: *** [xlib] Error 1
In my case above, I was using -ltcg which was being interpreted as an explicit library to include. I was using this option as it is listed on the qt 4.8 configure options as:
Use Link Time Code Generation
When I looked at the configure options using ./configure --help I noticed that this option isn't listed. Removing the option from my configure line fixed my issue.
what the proper steps to build Qt on Ubuntu?
Check the Qt supported Platforms.
Check Qt for X11 requirements.
3a. Check steps to install Qt on X11 platforms(along with build).
or
3b. Check steps to build static Qt.

/usr/bin/ld: cannot find -lfreetype Why? And how can I make it work?

Exact duplicate:
/usr/bin/ld: cannot find -lfreetype qt
Hi, I'm writing a cross-platform Qt application for a graduate project.
I've been working with Qt 4.3, but just recently upgraded to 4.5.
On my Windows machine, it works great. No problems. However, on my Linux machine, things aren't quite so nice.
I'm using the Qt creator and it goes through the compiling process making all the object files. But then it makes a call to:
g++ -Wl, -rpath, (all the .o files here) -L/media/HOME/Qt-Linux-4.5/qt/lib -lQtGui -L/media/HOME/Qt-Linux-4.5/qt/lib -L/usr/X11R6/lib -pthread -lfreetype -lgobject-2.0 -lrt -lglib-2.0 -ldl -lpthread
It gives me the error:
/usr/bin/ld: cannot find -lfreetype
collect2: ld returned 1 exit status
Now, I can locate libfreetype.so.6 and libfreetype.so.6.3.18 in my /usr/lib folders. I've tried running this inserting -L/usr/lib, but that didn't work. I've tried ln -s /usr/lib/libfreetype.so.6.3.18 libfreetype.so, I've tried editing the ld.so.conf file.
I'm trying this on an eeepc with Eeebuntu, if that helps.
Help!! I've been trying to get this to work for two days. I don't know what else I can do. Any suggestions?
Thanks much!
Brent
You missing dev librart, install libfreetypeX-dev, in debian lenny it would be apt-get install libfreetype6-dev
sudo apt-get install libfreetype6-dev
I've tried ln -s /usr/lib/libfreetype.so.6.3.18 libfreetype.so
Never do things like that unless you want to break your system and learn how to fix it
These I had to install on Kubuntu 9.04 64 bit in order to get a simple test app to build:
sudo apt-get install libfreetype6-dev
sudo apt-get install libavahi-gobject-dev
sudo apt-get install libSM-dev
sudo apt-get install libXrender-dev
sudo apt-get install libfontconfig-dev
sudo apt-get install libXext-dev
Edit: To get OpenGL to build I also had to install libgl1-mesa-dev and freeglut3-dev.
Edit2: Audio required libphonon-dev.
Thanks a lot! Installing the dev libraries got it to work. there were about five more libraries I had to install as well, but once I got them all, everything compiles just fine. Thanks a lot everyone!
When you did your ln -s /usr/lib/libfreetype.so.6.3.18 libfreetype.so, did you make sure that the libfreetype.so symlink ended up in /usr/lib too? To be sure, run ls -l /usr/lib/libfreetype.so and make sure it says what you expect it to.

Resources