installing C++ library with homebrew - c++

I'm trying to install a C++ library (gtkmm) for my project and to test this installation with a simple test file (the main from wikipedia page about gtkmm).
I did brew install gtkmm3, it installed it but when I compile with clang++ -Wall -Werror -Wextra -o test test.cpp it doesn't find my header :
test.cpp:15:10: fatal error: 'gtkmm-3.0/gtkmm.h' file not found
#include <gtkmm-3.0/gtkmm.h>
The header is located at ~/homebrew/include/gtkmm-3.0/gtkmm.h.
I tried :
adding $HOME"/homebrew/include" to $PATH and using #include <gtkmm-3.0/gtkmm.h> in my source file.
adding $HOME"/homebrew/include/gtkmm-3.0" to my $PATH and using #include <gtkmm.h> in my source file.
But I still can't compile.
How could I do?

Yes, use pkgconfig like this and it will tell you all the include paths and the link paths you need:
pkg-config --libs --cflags /usr/local/Cellar/gtkmm3/*/lib/pkgconfig/gdkmm-3.0.pc
Output
-D_REENTRANT -I/usr/local/Cellar/gtkmm3/3.18.0/include/gdkmm-3.0
-I/usr/local/Cellar/gtkmm3/3.18.0/lib/gdkmm-3.0/include
-I/usr/local/Cellar/glibmm/2.46.3/include/giomm-2.4
-I/usr/local/Cellar/glibmm/2.46.3/lib/giomm-2.4/include
-I/usr/local/Cellar/pangomm/2.38.1/include/pangomm-1.4
-I/usr/local/Cellar/pangomm/2.38.1/lib/pangomm-1.4/include
-I/usr/local/Cellar/glibmm/2.46.3/include/glibmm-2.4
-I/usr/local/Cellar/glibmm/2.46.3/lib/glibmm-2.4/include
-I/usr/local/Cellar/gtk+3/3.18.6/include/gtk-3.0
-I/usr/local/Cellar/glib/2.46.2/include/gio-unix-2.0/
-I/usr/local/Cellar/cairo/1.14.6/include/cairo
-I/usr/local/Cellar/libepoxy/1.3.1/include
-I/usr/local/Cellar/pango/1.38.1/include/pango-1.0
-I/usr/local/Cellar/harfbuzz/1.1.3/include/harfbuzz
-I/usr/local/Cellar/pango/1.38.1/include/pango-1.0
-I/usr/local/Cellar/atk/2.18.0/include/atk-1.0
-I/usr/local/Cellar/cairo/1.14.6/include/cairo
-I/usr/local/Cellar/cairomm/1.12.0/include/cairomm-1.0
-I/usr/local/Cellar/cairomm/1.12.0/lib/cairomm-1.0/include
-I/usr/local/Cellar/cairo/1.14.6/include/cairo
-I/usr/local/Cellar/pixman/0.32.8/include/pixman-1
-I/usr/local/Cellar/fontconfig/2.11.1/include
-I/usr/local/Cellar/freetype/2.6_1/include/freetype2
-I/usr/local/Cellar/libpng/1.6.20/include/libpng16
-I/usr/local/Cellar/libsigc++/2.6.2/include/sigc++-2.0
-I/usr/local/Cellar/libsigc++/2.6.2/lib/sigc++-2.0/include
-I/usr/local/Cellar/gdk-pixbuf/2.32.3/include/gdk-pixbuf-2.0
-I/usr/local/Cellar/libpng/1.6.20/include/libpng16
-I/usr/local/Cellar/glib/2.46.2/include/glib-2.0
-I/usr/local/Cellar/glib/2.46.2/lib/glib-2.0/include
-I/usr/local/opt/gettext/include
-L/usr/local/Cellar/gtkmm3/3.18.0/lib
-L/usr/local/Cellar/glibmm/2.46.3/lib
-L/usr/local/Cellar/pangomm/2.38.1/lib
-L/usr/local/Cellar/glibmm/2.46.3/lib
-L/usr/local/Cellar/gtk+3/3.18.6/lib
-L/usr/local/Cellar/pango/1.38.1/lib
-L/usr/local/Cellar/atk/2.18.0/lib
-L/usr/local/Cellar/cairo/1.14.6/lib
-L/usr/local/Cellar/glib/2.46.2/lib
-L/usr/local/Cellar/cairomm/1.12.0/lib
-L/usr/local/Cellar/cairo/1.14.6/lib
-L/usr/local/Cellar/libsigc++/2.6.2/lib
-L/usr/local/Cellar/gdk-pixbuf/2.32.3/lib
-L/usr/local/Cellar/glib/2.46.2/lib
-L/usr/local/opt/gettext/lib
-lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lglibmm-2.4 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lgio-2.0 -lcairomm-1.0 -lcairo -lsigc-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl
Then you can compile with:
clang++ $(pkg-config --libs --cflags /usr/local/Cellar/gtkmm3/*/lib/pkgconfig/gdkmm-3.0.pc) someFile.cpp -o someFile

Related

gtkmm-3.0 : Program Build Failed Msys2 Netbeans using pkg-config

Net-beans : 8.2
Windows : 10 64-bit
MinGW-w64 g++ : 7.2
I am trying to create an empty window using gtkmm 3.0 referring Programming with gtkmm book. I am referring (3.1) Simple Example from Chapter 3. Basics
#include <gtkmm.h>
int main(int argc, char *argv[])
{
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");
Gtk::Window window;
window.set_default_size(200, 200);
return app->run(window);
}
I have tried both
#include <gtkmm-3.0/gtkmm.h>
#include <gtkmm.h>
but my build fails under both circumstances.
g++ -c -g `pkg-config --cflags gtkmm-3.0` -std=c++14 -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
main.cpp:14:10: fatal error: gtkmm.h: No such file or directory
#include <gtkmm.h>
^~~~~~~~~
compilation terminated.
make[2]: *** [nbproject/Makefile-Debug.mk:68: build/Debug/MinGW-Windows/main.o] Error 1
make[2]: Leaving directory '/e/Projects/DiaplayL'
make[1]: *** [nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
make[1]: Leaving directory '/e/Projects/DiaplayL'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
I have installed msys2 in E drive. I was unable to install msys2 in C drive as the installation gets stuck at 0%.
I have added PKG_CONFIG_PATH :- E:\msys64\mingw64\bin in my environment variables. I am able look at include directories using --cflags and linked libraries using --libs
E:\Projects\DemoLcd>pkg-config --cflags gtkmm-3.0
-mms-bitfields -pthread -mms-bitfields -IE:/msys64/mingw64/include/gtkmm-3.0 -IE:/msys64/mingw64/lib/gtkmm-3.0/include -IE:/msys64/mingw64/include/atkmm-1.6 -IE:/msys64/mingw64/include/gdkmm-3.0 -IE:/msys64/mingw64/lib/gdkmm-3.0/include -IE:/msys64/mingw64/include/giomm-2.4 -IE:/msys64/mingw64/lib/giomm-2.4/include -IE:/msys64/mingw64/include/pangomm-1.4 -IE:/msys64/mingw64/lib/pangomm-1.4/include -IE:/msys64/mingw64/include/glibmm-2.4 -IE:/msys64/mingw64/lib/glibmm-2.4/include -IE:/msys64/mingw64/include/gtk-3.0 -IE:/msys64/mingw64/include/cairo -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/pango-1.0 -IE:/msys64/mingw64/include/atk-1.0 -IE:/msys64/mingw64/include/cairo -IE:/msys64/mingw64/include/cairomm-1.0 -IE:/msys64/mingw64/lib/cairomm-1.0/include -IE:/msys64/mingw64/include/cairo -IE:/msys64/mingw64/include/pixman-1 -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/freetype2 -IE:/msys64/mingw64/include/libpng16 -IE:/msys64/mingw64/include/harfbuzz -IE:/msys64/mingw64/include/glib-2.0 -IE:/msys64/mingw64/lib/glib-2.0/include -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/freetype2 -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/harfbuzz -IE:/msys64/mingw64/include/libpng16 -IE:/msys64/mingw64/include/sigc++-2.0 -IE:/msys64/mingw64/lib/sigc++-2.0/include -IE:/msys64/mingw64/include/gdk-pixbuf-2.0 -IE:/msys64/mingw64/include/libpng16 -IE:/msys64/mingw64/include -IE:/msys64/mingw64/include/glib-2.0 -IE:/msys64/mingw64/lib/glib-2.0/include -IE:/msys64/mingw64/include
E:\Projects\DemoLcd>pkg-config --libs gtkmm-3.0
-LE:/msys64/mingw64/lib -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lglibmm-2.4 -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lz -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lgio-2.0 -lcairomm-1.0 -lcairo -lsigc-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl
I am facing the same problem in other machine where msys2 is installed in C drive and installed without a hitch.
Kindly advice.
Solution is in 2 steps :
Modify $PKG_CONFIG_PATH in Msys2 shell to include the pkg_config folder containing .pc files for respective packages. eg: export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/mingw64/lib/pkgconfig or add the above command in /home//.bashrc
Create PKG_CONFIG_PATH environment variable with value as the Linux-type path i.e. /mingw64/lib/pkgconfig of the pkg_config folder containing .pc files for respective packages. e.g.: PKG_CONFIG_PATH = /mingw64/lib/pkgconfig

Undefined reference to wpa_ctrl functions in my C++ OpenFrameworks project. Need help integrating this c library

I'm working on a menu option to connect to wifi in my C++ application that is build using OpenFrameworks. I want to use the wpa_ctrl library but I can't get it to compile.
Code snippet:
NetworkWrapper.h:
#ifndef NETWORKWRAPPER_H_
#define NETWORKWRAPPER_H_
class NetworkWrapper {
public:
NetworkWrapper():
private:
struct wpa_ctrl* m_ctrl;
};
#endif
NetworkWrapper.cpp:
#include "NetworkWrapper.h"
extern "C" {
#include "wpa_ctrl.h"
}
NetworkWrapper::NetworkWrapper() {
m_ctrl = wpa_ctrl_open("wlan0");
}
Error:
***/NetworkWrapper.cpp:7: undefined reference to `wpa_ctrl_open'
collect2: error: ld returned 1 exit status
I've tried throwing around the include and using and not using extern "C" but it makes no difference seeing as wpa_ctrl.h is also enclosed in the extern "C" tag, albeit with #ifdef __cplusplus (which is defined, I double checked).
I'm pretty much out of ideas now. I should note that I tried enclosing wpa_ctrl.c in the extern "C" tags, which to my knowledge shouldn't compile(?). Which also gave the exact same result. This led me to manually compiling the wpa_ctrl library and copying to the obj directory but again: same result.
Thank you for taking the time to read my question, hope you can help!
* EDIT *
As per request my linking options (I trimmed it down a bit):
g++ -o bin/application_debug obj/linux64/Debug/src/main.o [...] obj/linux64/Debug/src/libs/wpa_ctrl.o [...] obj/linux64/Debug/src/common/NetworkWrapper.o [...] -Wl,-rpath=./libs:./bin/libs -Wl,--as-needed -Wl,--gc-sections -Wl,-rpath=./libs -liw -L../../../libs/fmodex/lib/linux64/ -lfmodex -L ./bin/libs -lSDL -lSDL_mixer -lcurl ../../../libs/glfw/lib/linux64/libglfw3.a ../../../libs/kiss/lib/linux64/libkiss.a ../../../libs/rtAudio/lib/linux64/libRtAudio.a ../../../libs/tess2/lib/linux64/libtess2.a ../../../libs/poco/lib/linux64/libPocoNet.a ../../../libs/poco/lib/linux64/libPocoXML.a ../../../libs/poco/lib/linux64/libPocoUtil.a ../../../libs/poco/lib/linux64/libPocoFoundation.a ../../../libs/poco/lib/linux64/libPocoNetSSL.a ../../../libs/poco/lib/linux64/libPocoNet.a ../../../libs/poco/lib/linux64/libPocoCrypto.a ../../../libs/poco/lib/linux64/libPocoUtil.a ../../../libs/poco/lib/linux64/libPocoXML.a ../../../libs/poco/lib/linux64/libPocoFoundation.a -L/usr/lib64 -lz -lgstapp-0.10 -lgstvideo-0.10 -lgstbase-0.10 -lgstreamer-0.10 -lgmodule-2.0 -pthread -lgthread-2.0 -pthread -lxml2 -ludev -lsndfile -lopenal -lssl -lcrypto -lpulse-simple -lpulse -lasound -lGLEW -lGLU -lGL -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lmpg123 -lglut -lX11 -lXrandr -lXxf86vm -lXi -lXcursor -ldl -lpthread -lfreeimage
So I finally found what I was doing wrong. For future visitors:
I needed to add the following defines in my makefile:
-D CONFIG_CTRL_IFACE -D CONFIG_CTRL_IFACE_UNIX

C++ CodeBlocks compile two source files

I have tried to compile those files by CodeBlocks which i have downloaded from here:
https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/frame?h=master
When i try to compile it with Code Blocks i get that error:
main.cpp|8|undefined reference to `ExampleWindow::ExampleWindow()'|
But i compile it like that from terminal it works:
g++ main.cc examplewindow.cc -o simple `pkg-config gtkmm-3.0 --cflags --libs`
Is there any idea how to make Code Blocks compile two source files ?
-------------- Build: Debug in youtube (compiler: GNU GCC Compiler)---------------
g++ -Wall -fexceptions -g -std=gnu++11 -pthread
-I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/atkmm-1.6 -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/gtk-3.0 -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -I/usr/include/atk-1.0 -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/harfbuzz -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 -I/usr/include/ -I/usr/lib/x86_64-linux-gnu/ -c /home/bahaa/programming/c++/youtube/main.cpp -o obj/Debug/main.o g++
-o bin/Debug/youtube obj/Debug/main.o -L/usr/lib/mysql -lmysqlclient -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 obj/Debug/main.o: In function main': /home/bahaa/programming/c++/youtube/main.cpp:8: undefined
reference toExampleWindow::ExampleWindow()'
/home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference to
ExampleWindow::~ExampleWindow()'
/home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference to
ExampleWindow::~ExampleWindow()' collect2: error: ld returned 1 exit
status Process terminated with status 1 (0 minutes, 1 seconds) 3
errors, 0 warnings (0 minutes, 1 seconds)
https://www.youtube.com/watch?v=3v3koVNb7hU&feature=youtu.be
The command you put in your terminal looks completely different from the command codeblocks is executing, so the fact that it does something different is logic.
However in the case of a undefined reference it usually means that you are forgetting an include somewhere. Where is ExampleWindow declared/defined? Is it in included in your main through one of the two includes you are doing?

Compiling and running GTK+ application on Windows 7

System: Windows7, 32 bit, GTK 2.24.10, mingw
I am trying to write basic helloworld.c type GTK based application. However, it doesn't run.
These are the steps which I followed.
Install MinGW.
Download GTK+ all in one bundle.
Extract content in C:\gtk folder.
Open cmd and go to C:\gtk\bin directory and run pkg-config --cflags --libs gtk+-win32-2.0
It prints list of compilation flags, and libraries to link your
project to.
Copy them and create a bath file as follows.
set VAR=FLAGS
start cmd
where VAR = GTK, and FLAGS = output of the previous command (pkg-config).
When you want to compile file use command : gcc foo.c %VAR%
D:\gtk>gcc -o project helloworld.c %GTK%
gcc: %GTK%: No such file or directory
helloworld.c:1:21: error: gtk/gtk.h: No such file or directory
helloworld.c: In function 'main':
helloworld.c:5: error: 'GtkWidget' undeclared (first use in this function)
helloworld.c:5: error: (Each undeclared identifier is reported only once
helloworld.c:5: error: for each function it appears in.)
helloworld.c:5: error: 'window' undeclared (first use in this function)
helloworld.c:9: error: 'GTK_WINDOW_TOPLEVEL' undeclared (first use in this function)
D:\gtk>gcc -Wall -g helloworld.c -o helloworld pkg-config --cflags gtk+-2.0 pkg-config --libs gtk+-2.0
gcc: pkg-config: No such file or directory
gcc: gtk+-2.0: No such file or directory
gcc: pkg-config: No such file or directory
gcc: gtk+-2.0: No such file or directory
cc1.exe: error: unrecognized command line option "-fcflags"
cc1.exe: error: unrecognized command line option "-flibs"
batch file in D:\gtk
set GTK=-mms-bitfields -IC:/gtk/include/gtk-2.0 -IC:/gtk/lib/gtk-2.0/include -IC:/gtk/include/atk-1.0 -IC:/gtk/include/cairo -IC:/gtk/include/gdk-pixbuf-2.0 -IC:/gtk/include/pango-1.0 -IC:/gtk/include/glib-2.0 -IC:/gtk/lib/glib-2.0/include -IC:/gtk/include -IC:/gtk/include/freetype2 -IC:/gtk/include/libpng14 -LC:/gtk/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
start cmd
helloworld.c
#include <gtk/gtk.h>
int main( int argc,
char *argv[] )
{
GtkWidget *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);
gtk_main ();
return 0;
}
Reference : Installing gtk and compiling using gcc under windows?
You could try these manual steps to start with:
1) At your command prompt run the pkg-config command to get your include flags:
c:\dev\gtk224\bin\pkg-config.exe --cflags gtk+-2.0
This is my output:
-mms-bitfields -Ic:/dev/gtk224/include/gtk-2.0 -Ic:/dev/gtk224/lib/gtk-2.0/include -Ic:/dev/gtk224/include/atk-1.0 -Ic:/dev/gtk224/include/cairo -Ic:/dev/gtk224/include/gdk-pixbuf-2.0 -Ic:/dev/gtk224/include/pango-1.0 -Ic:/dev/gtk224/include/glib-2.0 -Ic:/dev/gtk224/lib/glib-2.0/include -Ic:/dev/gtk224/include -Ic:/dev/gtk224/include/freetype2 -Ic:/dev/gtk224/include/libpng14
2) set the output from (1) to a variable GTK_INCLUDES:
C:\dev\1_repo\gtk_scratch>set GTK_INCLUDES=-mms-bitfields -Ic:/dev/gtk224/include/gtk-2.0 -Ic:/dev/gtk224/lib/gtk-2.0/include -Ic:/dev/gtk224/include/atk-1.0 -Ic:/dev/gtk224/include/cairo -Ic:/dev/gtk224/include/gdk-pixbuf-2.0 -Ic:/dev/gtk224/include/pango-1.0 -Ic:/dev/gtk224/include/glib-2.0 -Ic:/dev/gtk224/lib/glib-2.0/include -Ic:/dev/gtk224/include -Ic:/dev/gtk224/include/freetype2 -Ic:/dev/gtk224/include/libpng14
(make sure you use YOUR output from step (1))
3) do the same as step 1 for the library flags:
c:\dev\gtk224\bin\pkg-config.exe --libs gtk+-2.0
This is my output:
-Lc:/dev/gtk224/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
4) set output from (3) to a variable GTK_LIBS
C:\dev\1_repo\gtk_scratch>set GTK_LIBS=-Lc:/dev/gtk224/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
(make sure you use YOUR output from step (3))
5) make sure gtk+ and MinGW are on your path:
set PATH=c:\dev\MinGW\bin\;c:\dev\gtk224\bin
(make sure you set your path to YOUR mingw and gtk directories)
6) compile:
c:\dev\MinGW\bin\gcc.exe -g helloworld.c -o helloworld %GTK_INCLUDES% %GTK_LIBS%
7) when you are able to compile OK, copy what you did in steps 2,4,5 and 6 to a batch file so can compile you app just by running the batch file.
The error is right here.
pkg-config is a utility which helps (and I strongly recommend) to determine link and lib flags. The issue you got is that gcc interprets it as a parameter if you pass them like you do - you need to exectue them in a subshell (but I have no clue how to do that under windows shell or cygwin) under bash it is either $(pkconfig --libs gtk-2.0) or with backticks around instead of $(...)
D:\gtk>gcc -Wall -g helloworld.c -o helloworld pkg-config --cflags gtk+-2.0 pkg-config --libs gtk+-2.0
gcc: pkg-config: No such file or directory
gcc: gtk+-2.0: No such file or directory
gcc: pkg-config: No such file or directory
gcc: gtk+-2.0: No such file or directory
cc1.exe: error: unrecognized command line option "-fcflags"
cc1.exe: error: unrecognized command line option "-flibs"
Get same error when running hello, world program. Following solution work for me.
Instead of saving your helloworld.c at any arbitrary place, put it inside of
MinGW > msys > 1.0 > home > "Name of Your home folder" > helloworld.c
Now, open msys.bat and write the command to run program. In my case it was:
gcc hello.c -o hello `pkg-config --cflags --libs gtk+-3.0`
And it works for me!

Gtkmm compiling error

OS: Windows 7
Compiler: MinGW
IDE: Code::Blocks
I just installed Gtkmm on my computer in the folder C:/gtkmm/ and set up an example program. When I compiled it, it gave the error "gtkmm.h: No such file or directory"
I tried setting the PATH variable to C:/gtkmm/include and C:/gtkmm/gtkmm-2.4, but neither worked. Then I tried using #include "C:/gtkmm/include/gtkmm-2.4/gtkmm.h" and that just gave a ton of errors saying that it doesn't know where a few dozen files are.
I've also heard that you need to put pkg-config gtkmm-2.4 --cflags --libs in the compiler options, but that didn't work either.
What am I doing wrong and how do I fix it?
pkg-config is a helper function for adding cflags and lib paths to the compiler line.
What you will need to do is add the libraries and cflags path to the compiler line. I am not 100% sure how to do that in code::blocks., though
In ubuntu 11.04, you need all these to compile even a simple gtkmm program:
Libs (pkg-config --libs gtkmm-2.4:
-pthread -lgtkmm-2.4 -latkmm-1.6 -lgdkmm-2.4 -lgiomm-2.4 -lpangomm-1.4 -lgtk-x11-2.0 -lglibmm-2.4 -lcairomm-1.0 -lsigc-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lm -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
cflags paths (pkg-config --clfags gtkmm-2.4):
-I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gio-unix-2.0/ -I/usr/include/gtkmm-2.4 -I/usr/lib/gtkmm-2.4/include -I/usr/include/atkmm-1.6 -I/usr/include/giomm-2.4 -I/usr/lib/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/pangomm-1.4/include -I/usr/include/gtk-2.0 -I/usr/include/gtk-unix-print-2.0 -I/usr/include/gdkmm-2.4 -I/usr/lib/gdkmm-2.4/include -I/usr/include/glibmm-2.4 -I/usr/lib/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include -I/usr/include/cairomm-1.0 -I/usr/lib/cairomm-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/lib/gtk-2.0/include -I/usr/include/gdk-pixbuf-2.0
Basically you would have to change every instance of /usr/include/ and /usr/lib/ to c:\path-to-library\
I am not sure how much of the above you need with MinGW, but with GCC on Linux, dropping any of them makes gtkmm programs not compile. Hope that at least puts you on the right path.
What do you mean with PATH variable? The global windows search PATH for executables? That would be wrong.
You need to look in your IDE for Include search path or header search path or something like that.
Does that pkg-config command work for you when you execute it on the command line? Such a pkg-config when used on a unix system is enclosed in backticks ` which causes it to be substituted by it's output. Don't know if your IDE can do that but if it works from the command line you have at least a list of all includes needed.
Use autotools C++ project. You need only edit two files configure.ac and Makefile.am.
Add this line to configure.ac
PKG_CHECK_MODULES([GTKMM], [gtkmm-3.0])
and these lines to Makefile.am
program_CPPFLAGS = $(GTKMM_CFLAGS)
program_LDADD = $(GTKMM_LIBS)