I am working on a project that I need to display video to a window. So I do some research and find out GStreamer lib is probably a good way to go since I have a GUI written with GTK. However, after 2 hours trying to install and compile GStream on my Mac, I still get:
error: gts/gts.h: No such file or directory
What I did is install Gstreamer SDK for Mac OS from the official website. Export path:
export PATH=/Library/Frameworks/GStreamer.framework/Version/0.10/Headers:$PATH
Compile:
gcc test.c `pkg-config --cflags --libs gtk+-2.0` `pkg-config --cflags --libs gtk-1.0`
But I have no luck!. Please help!!!
First of all: You can't specify GCC's include path using the PATH variable. Its sole purpose is for the shell (or to be more specific: for the various flavors of exec()) to find executables you want to run.
You might want to modify your gcc command line like that (gstreamer-0.10 instead of gst-0.10):
gcc test.c `pkg-config --cflags --libs gtk+-2.0 gtk-1.0 gstreamer-0.10`
If that still doesn't work, look at the output of the pkgconfig command (by running it alone):
pkg-config --cflags --libs gtk+-2.0 gtk-1.0 gstreamer-0.10
That should give you either a list of gcc flags or an error message that should help you resolve your issue.
Related
I would like to force Xcode 14 to compile my simple GTK2 project.
I couldn't find in Google how to add some flags to the compiler.
Could you please give some hints or screenshots?
This what I'd like to achieve is to Run the project using the "play" button or shortcut: CMD + R
I am using a following command to compile my project:
gcc-12 -Wall -g hello.c -o helloworld `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
However it also works with clang compiler:
clang-g hello.c -o helloworld `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
In addition to that, I'd like also to resolve the problem that Xcode can't see GTK library.
Thank you for any help.
i've installed in my windows 10 system GTK3.0 for mingw64 by MSYS2 but i've got a problem with pkg-config. When i write in the shell:
$ pkg-config --cflags --libs gtk+-3.0
I got the following error:
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk+-3.0', required by 'virtual:world', not found
What's the deal?
I am trying to learn gtk and following this link : http://zetcode.com/gui/gtk2/firstprograms/ I was able to get a basic program to run. The way to compile the code was to use the command:
gcc -o simple simple.c `pkg-config --libs --cflags gtk+-3.0`
I want to understand what the flags pkg-config --libs --cflags gtk+-3.0 mean.
I tried searching the man page for the flags pkg-config, --libs and --cflags, but couldn't find them. I would feel fairly satisfied if I understood what that snippet of text inside the `` actually means.
To compile a program using GTK+ 3.0 you need to provide compile options to tell the compiler where to look for include files and library files.
You can either specify them directly with the appropriate compiler options.
Or you can use the flags that were configured when you installed the GTK+ packages.
These flags can be retrieved using pkg-config command.
Putting the command in `` causes the content to be executed and being replaced by the output of the command.
This will provide the compile flags (--cflags) and library options (--libs) needed to build your application.
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.
I am using MinGW and I have set the path for the same in the Environment Variables. I have also set the path for GTK in the Environment Variables.
MInGW has been set up successfully since I am able to use the gcc commands to compile regular C programs.
Even GTK has been set up successfully (confirmed by entering pkg-config --cflags gtk+-3.0 in cmd which prints out a list of variables and also ran a already compiled GTK application succesfully).
I have also set the path for pkgconfig in the Environment Variables.
Variable Name-PKG_CONFIG_PATH and Value-C:\gtk\lib\pkgconfig
Even after the complete set up, there are some errors which occur when I try compiling a GTK program.
Command used:
gcc hello.c -o hello 'pkg-config --cflags --libs gtk+-3.0'
Note: I have used ` in the actual command and not '(used ' here to prevent highlighting).
Errors:
pkg-config no such directory found.
gtk+-3.0 no such directory found
unrecognized command line option --cflags unrecognized command line
option --labs
Tools I tried:
Windows cmd
MingW Shell
MSYS2
Cygwin Terminal (I haven't set up Cygwin path in the environment variables to prevent errors between Cygwin and MingW)
Can someone help me in figuring out what's the actual issue even after completing all the set up steps I mentioned above? Please help me!
Forums I already checked out:
Compiling and running GTK+ application on Windows 7
http://www.tarnyko.net/repo/gtk3_build_system/tutorial/gtk3_tutorial.htm
And more...But nothing has helped me so far!
So I understand you have been using:
gcc hello.c -o hello `pkg-config --cflags --libs gtk+-3.0`
You appear to be trying to be clever with pkg-config. Have you tried using --libs & --cflags separately?
e.g.:
gcc `pkg-config --cflags gtk+-3.0` -o hello hello.c `pkg-config --libs gtk+-3.0`
For more info see here