According to a tutorial on
https://developer.gnome.org/gtk-tutorial/stable/c39.html
for making GUI for c-apps the compiling syntax is
gcc base.c -o base `pkg-config --cflags --libs gtk+-2.0`
Its all about these backticksymbols and seem to be suited for POSIX on linux.
If backticks in this context is not allowed in CMD-windows - is there a workaround for compiling a GTK-app in c easily?
Try to use for example GTK+ for Windows (MinGW). Also see related questions How to hide command prompt for my Windows Gtk Apps? and Help compiling GTK+ on Windows using MinGW.
Related
I want to learn gtk to make GUI using c language I installed all the stuff required as per the website installation guide but then I don't know what to do next how to compile the code, I use atom for writing my c code sometimes also dev c++, so can I set up gtk in atom or dev c++ and compile my code and if not is there any good alternatives for compiling gtk code?
If you are using Dev-C++ (that project is ancient BTW, I would suggest moving on from that) I expect you are working in a Windows environment? I would suggest using MSYS2 for compiling GTK applications in Windows:
https://www.msys2.org/
MSYS uses the Pacman package manager for its shell. You will need to download the following package in order to compile GTK applications in MSYS/MinGW:
pacman -S mingw-w64-x86_64-gtk3
You should also download gcc and pkg-config to compile:
pacman -S pkg-config gcc
Note that pkg-config is generally used to compile GTK applications due to the number of dependencies that are required (Glib, Cairo, etc.). I can't imagine you possibly compiling a GTK application using Dev-C++ as a result. You should add the following line to your .bashrc file (this will be located in the home directory of MSYS):
export PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH"
A typical compile line for a GTK application would look like this:
gcc -o <program> <program>.c $(pkg-config gtk+-3.0 --cflags --libs) -rdynamic -lm
I have a perfectly working C program using SDL that I can compile with
gcc main.c -o program `sdl-config --libs` -lSDL
The program is simple, it comes up with a black window and waits for the user to close it. No problems or errors. I have MinGW installed and I'm trying to use x86_64-w64-mingw32-gcc to cross-compile it; I would like to know how to cross-compile this for Windows on Linux and include the necessary libraries.
You can invoke MinGW’s GCC like your Linux version, but you might need to replacesdl-config with some manual configuration like so:
x86_64-w64-mingw32-gcc -Ipath/to/SDL/headers \
-Lpath/to/SDL/libs \
-o program main.o \
-lSDL -lSDLmain
You will need to download SDL.lib and SDLmain.lib. I believe they are part of the development zip. (Edit: as noted in the comments, you might not need to use the libs but can just use the DLLs.)
This might pop up a console window when running. Pass in the -mwindows flag to target the Windows subsystem instead.
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.
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.
I am working on a program which uses ncurses which will be used on embedded systems. Since these systems won't have ncurses installed I need to statically link the library. However if I try to build it like this
gcc -static ncurs.c -o ncurs -l:libncurses.a
or
gcc -static ncurs.c -o ncurs -lncurses
I get a ton of errors like this:
(.text+0x48): undefined reference to `SP'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_slktouch.o): In function `slk_touch':
normal compilation works fine.
I have searched for hours but I can't find any good information...
platform of development is stripped down debian system.
I guess you may need additional library, can you try -lncurses -ltinfo.
You can check on your system what the linker library flags for ncurses using command
pkg-config --static --libs ncurses
on my system, I got
-lncurses -ltinfo
try adding -ltinfo to the end of your commandline