How to use kplot (Cairo plotting library) without installing it - c

kplot is a UNIX programming library for plotting graphs on a Cairo surface. The source code is available here.
After downloading the source code I extraced it to the directory kplot-master and cd into it. Simple ls now shows
array.c
border.c
bucket.c
buffer.c
....
example0.c
example1.c
....
I am using Ubuntu 14.04 LTS. Cairo is installed in my system and I tested it by successfully compiling C codes available in [zetcode dot com slash gfx slash cairo slash cairobackends slash] (Sorry as I am not allowed to link more than two).
I am new to GTK and Cairo plotting library and would like help in the following directions:
I do not want to install kplot in my system.
I just want to learn how kplot uses Cairo.
When I use the following command:
gcc example0.c -o example `pkg-config --cflags --libs gtk+-3.0`
it produces the following error message:
example0.c:17:20: fatal error: compat.h: No such file or directory
#include "compat.h"
^
compilation terminated.
It will be very helpful if somebody shows me how to test those kplot examples without installing it.

There is no need to install.
First you will need to compile the kplot library. For that, cd to the kplot directory and run a make command. This will generate the file compat.h. After that you will be able to compile example by example with make example(n) command, or with gcc example(n).c -o example(n) `pkg-config --cflags --libs gtk+-3.0` libkplot.a -lbsd -lm command.
If you have GTK+-3.0 and Cairo dev libraries installed, everything should go well.

Related

C compile error - #include "cmakeconfig.h" - No such file or directory

On a Linux Mint 64bit system using gcc
I'm trying to compile the MiniBrowser example included with the WebKit package that I downloaded. webkitgtk-2.22.3
I have successfully setup the WebKit library, but when I try to compile the Tools/MiniBrowser example I get the error message given in the question title.
NOTE: There is no file on my system called cmakeconfig.h
NOTE: There are a few files called CMakeLists.txt that I do not know what to do with.
NOTE: Compiled using:
gcc `pkg-config --cflags gtk+-3.0 webkit2gtk-4.0 gstreamer-1.0` -o main main.c `pkg-config --libs gtk+-3.0 webkit2gtk-4.0 gstreamer-1.0`
As per the question comments. Use the Linux command cmake with the argument CMakeLists.txt which hopefully will generate the file cmakeconfig.h
$ cmake CMakeLists.txt

Type fatal error: gtk/gtk.h: No such file or directory during Eclipse (Oxygen) compilation

I've some errors compiling C code with GTK widgets in Eclipse, indicating that gtk/gtk.h cannot be found. I've already installed GTK+2 and GTK+3; and also included the header paths for GTK but it seems that the Eclipse environment is still unable to find the required header.
Greatly appreciate any advice from the community!
You didn't provide enough information to actually know what is going on, but I guess the include paths you configured are somehow wrong.
My advice would be that you should use pkg-config to obtain the correct compiler flags instead of adding include dirs etc. manually.
This will give you a list of all packages, pkg-config knows are installed on your machine:
pkg-config --list-all
The GTK package should be something like gtk+-3.0
Use this to get the CFLAGS for use with GTK3:
pkg-config --cflags gtk+-3.0
And here is how to get the libraries for the linker stage:
pkg-config --libs gtk+-3.0
So instead of doing something like this:
# Don't do this
gcc -I... main.c
... use something like this:
gcc $(pkg-config --cflags gtk+-3.0) ... main.c
Read the man page of pkg-config for more informations.
There was an Eclipse plugin for pkg-config support, but it doesn't seem to work with Oxygen. I managed to get a building example with these settings, though Eclipse itself won't find the includes.

DLL: File format not recognised when compiling C with MinGW on Linux for Windows

I'm using MinGW on Linux (Ubuntu, specifically) to compile a C program for Windows. I'm using a library called SFML, and it's bindings called CSFML. I'm using -L and -l to locate the libraries, but when I compile I get this error:
win32/dll/csfml-audio-2.dll: file not recognized: File format not recognised
I've got no idea why. Here's the command I'm using to compile:
sudo i686-w64-mingw32-gcc -o wandering src/main.c src/constants.c src/Display/display.c **...some more c files in here...** src/Generation/perlinnoise.c $(pkg-config --libs --cflags glib-2.0) $(pkg-config --libs --cflags gee-1.0) -Iwin32/CSFML-2.1/include -Lwin32/dll -lcsfml-audio-
Does anyone know why it's happening? I can compile C programs without SFML but with MinGW just fine...
The DLL has a PE32 executable file header. It's not used for the linker. You should use the import library instead. This file has the extension LIB.
I heard there are some gcc compiler versions out there than generate an import library from a DLL on the fly. It looks like your version doesn't.
From command line it seem's trying to use sudo i686-w64-mingw32-gcc 64 bit compiler and supplying 32 bit DLL i.e. win32/dll/csfml-audio-2.dll. change to x64/dll/csfml-audio-2.dll. It should work fine.

OpenCV - C library is not working in my Ubuntu11.10

Resently I'm installed Opencv in my machine. Its working in python well(I just checked it by some eg programs). But due to the lack of tutorials in python I decided to move to c. I just run an Hello world program from http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/
while compiling I got the following error
hello-world.c:4:16: fatal error: cv.h: No such file or directory
compilation terminated.
I'm new in opencv
Qn : Could you please report what may be the problem - and how I run my helloworld program in c?
Your compiler cannot find your cv.h include file. If you installed from your package manager, it is probably in /usr/include/opencv/. You need to add that your include search path. If you are compiling from the command line use -I to specify additional include directories. It will be something like -
gcc -I /usr/include/opencv/ -o helloworld helloworld.c
If you are using Eclipse,
Right click on the project and select properties.
Select C/C++ General -> Path and Symbols.
Select Includes tab.
In Languages list, select 'GNU C' or 'GNU C++' depending on which you are using.
Press 'Add...' button and add /usr/include/opencv/
Save and rebuild.
You need to show compiler path to cv.h file. The quick way to find it is to do (on Ubuntu):
find /usr -name "cv.h"
/usr/local/include/opencv/cv.h
Just add this to the compiler:
gcc -I/usr/local/include/opencv -o helloworld helloworld.c
Since you asking this question your compiler might also have problems linking your program to opencv libraries. Just do the same thing only for library files:
find /usr -iname "libopencv*"
/usr/local/lib/libopencv_flann.so
...
add this folder the same way and specify libraries you want to use:
gcc helloworld.c -I/usr/local/include/opencv -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -o helloworld
that should probably compile. There is a also a short cut you can take and instead of all that steps just use the following command
gcc helloworld.c `pkg-config --cflags --libs opencv` -o helloworld
that should take care of all the work of locating required files for you and let you focus on the fun coding part.
maybe you just installed the opencv package.
But, as you want to use opencv in your C program, you may also install the package named just like opencv-devel. If you haven't, install it and than use it as #iagreen said.
Best wishes to you.

How do I use glib in kdevelop?

I'm using Kdevelop 4.0 to make a new app, and now I'm trying to include the glib but I cannot do it.
I have installed via apt-get install in Ubuntu 10.04 and it's installed in /usr/include/glib-2.0, but when I try to include the library with
#include <glib.h>
and try to compile it, it tells me that "such file doesn't exists".
What am I doing wrong?
Thanks!
You need to pass the path to the glib libraries and headers to your compiler.
glib provides the pkg-config script to generate what you need. To compile correctly, you would need to do something like the following:
cc `pkg-config --cflags --libs glib-2.0` hello.c -o hello
This answer is basically a quick summary of what is provided in the glib documentation here:
http://developer.gnome.org/glib/2.28/glib-compiling.html
I'm not familiar with KDevelop, but if it's like Eclipse or Visual Studio, there is a menu for adding libraries and include folders to a project. Try the following:
Run pkg-conf --cflags glib-2.0
Add output to include directories for your project.
Run pkg-conf --libs glib-2.0
Add output to libraries path for your project.
A quick look on google suggests that you can find these menus at the following locations:
Include Directories
Automake manager> options> Includes> Directories
Library Directories
Automake Manager > Options >Libraries > Link Libraries

Resources