I'm currently trying to use the "QSerialPort" library on a Virtual Machine with Debian on it and can't seem to make it work. It looks like the Library straight up doesn't exist on my machine. It doesn't auto-complete when I write it out and when I try compiling I get this.
/home/debian/Downloads/mainmenu.h:15: error: QSerialPort: No such file or directory
#include <QSerialPort>
^
So I'm pretty sure I just don't have the library. Even though my version of Qt is said to have it.
-Qt Creator 4.2.0
-Based on Qt 5.7.1 (GCC 6.3.0 20170415, 64 bit)
I even have an older version of Qt creator on my Windows OS and it has the library.
I was told to get the library myself by doing this:
git clone git://code.qt.io/qt/qtserialport.git
mkdir qtserialport-build
cd qtserialport-build
qmake ../qtserialport/qtserialport.pro
sudo make install
but I can't even get through the first line before getting this:
git clone git://code.qt.io/qt/qtserialport.git
Cloning into 'qtserialport'...
fatal: unable to connect to code.qt.io:
Also tried to install the Package: libqt5serialport5 (5.2.1-1)
and it pretty much changed nothing.
You need to download and install. Just follow my instructions given below, it will help you to fix the problem.
You are very close man (Also tried to install the Package: libqt5serialport5 (5.2.1-1))
1) You have to install (via Terminal):
sudo apt-get install libqt5serialport5
sudo apt-get install libqt5serialport5-dev
2) add in the .pro file
QT += core serialport
3) int the .h file add:
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
4) Example Device Info
serial -> setPortName("/dev/ttyACM3"); // just example for my device
serial -> setBaudRate(QSerialPort::Baud115200);
serial -> setDataBits(QSerialPort::Data8);
serial -> setParity(QSerialPort::NoParity);
serial -> setStopBits(QSerialPort::OneStop);
serial -> setFlowControl(QSerialPort::NoFlowControl);
serial -> open(QIODevice::ReadWrite);
It is probably the best option.
Alright! I figured it out.
First problem, was accessing a git library through a Firewall/Virtual Machine.
So instead of using the git link:
git://code.qt.io/qt-creator/qt-creator.git
I used the http link, which worked:
http://code.qt.io/qt-creator/qt-creator.git
Still had some issues until I followed these steps(I didn't download the dev version of the package, I guess):
1)
sudo apt-get install libqt5serialport5
sudo apt-get install libqt5serialport5-dev
2) add in the .pro file
QT += serialport
3) int the .h file add:
#include <QtSerialPort/QSerialPort>
my problem is the following :
In order to build some specific library I have to install GCC on a red hat without access to Internet and no way to use yum.
For now I did :
1)I installed gcc-x86_64-linux-gnu (and it's dependencies)
2) I created symbolic links in /usr/bin for the following installed executables : /usr/bin/x86_64-linux-gnu-cpp, /usr/bin/x86_64-linux-gnu-gcc, /usr/bin/x86_64-linux-gnu-gcov
using sudo ln -s /usr/bin/x86_64-linux-gnu-<end> <end>
So I have functional gcc cpp and gcov command.
3) I tested a ./configure on my library to build and get GCC saying that the C compiler isn't able to create C executable. I so tested to create a simple hello world C program.
#include<stdio.h>
int main(void){
printf("hello world!\n");
return 0;
}
when running gcc ./hello.c -o helloI got the this error : "fatal error : stdio.h : no such file or directory".
4) I did a ls /usr/include | grep .h but found nothing. Conclusion : standard C libs aren't installed.
5) I so installed glibc-devel to import the standard C library, and now the same command show numerous C files, including the stdio.h file.
But my GCC still raising the same fatal error.
Any idea about what should I do make to make it work ?
I don't think the problem here is related to x86 / x64 problem as it is suggested in this question
From your post i assume that this is related to improper installation, before installing a package make sure you use the proper package to the proper distribution as compatibility issues may arise with 32 Bit or 64 Bit OS package. You could try the below method by using a Red Hat Boot CD.
Install rpm from CDROM/DVD
Mount your RHEL Linux CD/DVD and install the following packages using rpm command:
$rpm -ivh gcc*
I try to run simple test.cpp from Twinklebar SDL tutorial, I get this error:
test.cpp:2:10: fatal error: 'SDL2/SDL.h' file not found
So I look up the sdl development package in Ubuntu/Mint:
aptitude search sdl | grep 2
All I can find is this:
libsdl1.2-dev
Does this mean my only option is to install from sources?
It depends which Ubuntu version you are running but yes, there is a libsdl2 package for Ubuntu: http://packages.ubuntu.com/search?keywords=sdl2
The package you want is called libsdl2-dev.
Also, about the #include <SDL/SDL.h> line, it seems the recommended way doing it is by adjusting your compiler flags to add SDL's include pah and use #include "SDL.h". See https://forums.libsdl.org/viewtopic.php?t=5997 for more details on that.
i dont have internet connection, so i installed gcc on my linux system manually through its debian package. but i am not able to compile any c code.
here is my sample c code.
#include <stdio.h>
main()
{
printf("Hellp world");
return 0;
}
the error that it shows:
ocpe#blrkec241972d:~$ gcc -o hello hello.c
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function âmainâ:
hello.c:4: warning: incompatible implicit declaration of built-in function âprintfâ
I think i have not installed all the dependencies of compiler. Plz suggest me descriptive way to install it correctly..
Assuming by "installed manually", you mean "using dpkg -i", then you need to also install libc6-dev. I suggest further installing, at very minimum, build-essential and everything it depends on.
Debian actually has a few programs to help with offline package installation. One option is of course to use CD/DVD images. Another is to use something like apt-offline.
On my Debian system, the header files are in another package libc6-dev. You're probably missing that (and some others as well, I would guess).
What about this gcc -Wall hello.c -o hello -I/usr/include/stdio.h?
You can see your include search path by using:
echo | gcc -v -x c -E -
On my Ubuntu Linux machine i can see this output for the previous command:
#include \"...\" search starts here:
/usr/lib/gcc/i686-linux-gnu/4.6.1/include
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed
/usr/include/i386-linux-gnu
/usr/include
EDIT :
Install build-essential
Download from here : http://packages.debian.org/squeeze/i386/build-essential/download (assume you are 32 bits), and install dowloaded package like this:
dpkg -i build-essential.deb
I need to determine which version of GTK+ is installed on Ubuntu
Man does not seem to help
This suggestion will tell you which minor version of 2.0 is installed. Different major versions will have different package names because they can co-exist on the system (in order to support applications built with older versions).
Even for development files, which normally would only let you have one version on the system, you can have a version of gtk 1.x and a version of gtk 2.0 on the same system (the include files are in directories called gtk-1.2 or gtk-2.0).
So in short there isn't a simple answer to "what version of GTK is on the system". But...
Try something like:
dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'
to list all the libgtk packages, including -dev ones, that are on your system. dpkg -l will list all the packages that dpkg knows about, including ones that aren't currently installed, so I've used grep to list only ones that are installed (line starts with i).
Alternatively, and probably better if it's the version of the headers etc that you're interested in, use pkg-config:
pkg-config --modversion gtk+
will tell you what version of GTK 1.x development files are installed, and
pkg-config --modversion gtk+-2.0
will tell you what version of GTK 2.0. The old 1.x version also has its own gtk-config program that does the same thing. Similarly, for GTK+ 3:
pkg-config --modversion gtk+-3.0
This isn't so difficult.
Just check your gtk+ toolkit utilities version from terminal:
gtk-launch --version
get GTK3 version:
dpkg -s libgtk-3-0|grep '^Version'
or just version number
dpkg -s libgtk-3-0|grep '^Version' | cut -d' ' -f2-
You can use this command:
$ dpkg -s libgtk2.0-0|grep '^Version'
You could also just compile the following program and run it on your machine.
#include <gtk/gtk.h>
#include <glib/gprintf.h>
int main(int argc, char *argv[])
{
/* Initialize GTK */
gtk_init (&argc, &argv);
g_printf("%d.%d.%d\n", gtk_major_version, gtk_minor_version, gtk_micro_version);
return(0);
}
compile with ( assuming above source file is named version.c):
gcc version.c -o version `pkg-config --cflags --libs gtk+-2.0`
When you run this you will get some output. On my old embedded device I get the following:
[root#n00E04B3730DF n2]# ./version
2.10.4
[root#n00E04B3730DF n2]#
Try,
apt-cache policy libgtk2.0-0 libgtk-3-0
or,
dpkg -l libgtk2.0-0 libgtk-3-0
I think a distribution-independent way is:
gtk-config --version
You can also just open synaptic and search for libgtk, it will show you exactly which lib is installed.
Try:
dpkg-query -W libgtk-3-bin
Because apt-cache policy will list all the matches available, even if not installed, I would suggest using this command for a more manageable shortlist of GTK-related packages installed on your system:
apt list --installed libgtk*
This will get the version of the GTK libraries for GTK 2, 3, and 4.
dpkg -l | egrep "libgtk(2.0-0|-3-0|-4)"
As major versions are parallel installable, you may have several of them on your system, which is my case, so the above command returns this on my Ubuntu Trusty system:
ii libgtk-3-0:amd64 3.10.8-0ubuntu1.6 amd64 GTK+ graphical user interface library
ii libgtk2.0-0:amd64 2.24.23-0ubuntu1.4 amd64 GTK+ graphical user interface library
This means I have GTK+ 2.24.23 and 3.10.8 installed.
If what you want is the version of the development files, use:
pkg-config --modversion gtk+-2.0 for GTK 2
pkg-config --modversion gtk+-3.0 for GTK 3
pkg-config --modversion gtk4 for GTK 4
(This changed because the + from GTK+ was dropped a while ago.)
To make the answer more general than Ubuntu (I have Redhat):
gtk is usually installed under /usr, but possibly in other locations. This should be visible in environment variables. Check with
env | grep gtk
Then try to find where your gtk files are stored. For example, use locate and grep.
locate gtk | grep /usr/lib
In this way, I found /usr/lib64/gtk-2.0, which contains the subdirectory 2.10.0, which contains many .so library files. My conclusion is that I have gtk+ version 2.10. This is rather consistent with the rpm command on Redhat: rpm -qa | grep gtk2, so I think my conclusion is right.
To compile and link a GTK program with pkg-config, we need the library name instead of the actual version number. For example, the following command compiles and links a GTK program that uses the GTK4 library:
gcc -o program program.c `pkg-config --cflags --libs gtk`
To obtain the library name for GTK, use the following command:
pkg-config --list-all | grep gtk