Installing a graphics library on linux - linux

I'm not a linux expert, and I'm trying to install a 2D graphics library on Ubuntu 10.10. I need to make a 2D display and after a little online research, GooCanvas seems like it will fit the bill.
I'm frustrated because it simply won't install and I don't get what I am supposed to do.
Here's what I did.
1> git clone git://git.gnome.org/goocanvas #built a goocanvas directory
2> cd goocanvas
3> ls
AUTHORS ChangeLog demo goocanvas.doap NEWS src
autogen.sh configure.in docs MAINTAINERS po TODO
autom4te.cache COPYING goocanvas-2.0.pc.in Makefile.am README
4> less README #here's what it says
To build it run './configure' and 'make'. To run the demo cd into 'demo' and
run './demo'. (Or run ./simple-demo for the very simple demo, or ./mv-demo
for the model-view demo.)
5> ./configure # error: bash: ./configure: No such file or directory
6> find . -name "configure*" -print #there aren't any other configure scripts?
'make; and 'make install' don't work either.
OK, I'm frustrated. Why does it say run configure if there isn't one? How do I install this thing?
Does anyone know an easy to use graphics library for ubuntu that will actually work. and can be easily installed?

Cairo, which is usually assumed when talking about GTK, is a good 2D library. Installing should be easy as this will be in your distributions repository (from the command line as root run apt-get install libcairo2-dev).
Now that I think about it - your new enough to Linux not to look at your repository for software first - learn to do that! I checked and found Ubuntu universe already has goocanvas, just apt-get install libgoocanvas-dev and you should be good to go.

Does anyone know an easy to use graphics library for ubuntu that will actually work.
and can be easily installed?
What is wrong with the big ones:
Qt
gtk
EFL (The Enlightenment libs)

Their instructions are out of date, execute the autogen.sh file first. You'll need the gtk-doc-tools and some other packages to support compiling things.
Edit 1:
Looks like it needs GTK 3.0, glib 2.28+, and Cairo 1.1+ - those are pretty modern. I'm not sure what Ubuntu 10.10 has them (I'm on 10.04), launch Synaptic Package Manager and search for libgtk the header files are in dev packages.
Edit 2:
What sort of graphics package are you looking for? SDL may work, or Cairo.

Using SDL
If you want to use graphics.h on Ubuntu platform you need to compile and install libgraph. It is the implementation of turbo c graphics API on Linux using SDL.
It is not very powerful and suitable for production quality application, but it is simple and easy-to-use for learning purpose.
You can download it from http://download.savannah.gnu.org/releases/libgraph/libgraph-1.0.2.tar.gz.
First install build-essential by typing
sudo apt-get install build-essential
Intall some additional packages by typing
sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 \
guile-1.8-dev libsdl1.2debian libart-2.0-dev libaudiofile-dev \
libesd0-dev libdirectfb-dev libdirectfb-extra libfreetype6-dev \
libxext-dev x11proto-xext-dev libfreetype6 libaa1 libaa1-dev \
libslang2-dev libasound2 libasound2-dev
Now extract the downloaded libgraph-1.0.2.tar.gz file.
Goto extracted folder and run following command
./configure
make
sudo make install
sudo cp /usr/local/lib/libgraph.* /usr/lib
Now you can use #include on ubuntu platform
Compile it using gcc demo.c -o demo -lglut -lGL
/* demo.c*/
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glu.h>
void setup() { glClearColor(1.0f, 1.0f, 1.0f, 1.0f); }
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0.0f, 0.0f, 0.0f);
glRectf(-0.75f,0.75f, 0.75f, -0.75f);
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(800,600);
glutCreateWindow("Hello World");
setup();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Run it using ./demo

Check this out: We have developed a 2d Graphics library and Windowing System(GWS): https://github.com/MnMInfoTech/GWS

Related

Trouble with QSerialPort with qtcreator on Debian

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>

How to make GCC detect standard C library?

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*

Installing SDL2 on Linux

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.

manual installation of gcc

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

How do you find out which version of GTK+ is installed on Ubuntu?

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

Resources