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
Related
I'm a beginning C++ programmer and want to use Code::Blocks IDE on Debian based Linux to write some GUI programs.
Therefore I would like to use gtkmm 3.0 with this code:
#include <gtkmm/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);
}
The compiler gives me this error:
fatal error: gtkmm/gtkmm.h: No such file or directory
I followed these steps to install gtkmm:
Installed Code::Blocks and was able to compile non-GUI programs.
Then installed gtkmm-3.0 with synaptic.
In Code::Blocks settings > compiler > compiler settings > other compiler options I set:
pkg-config --cflags gtk+-3.0
In codeblock settings > compiler> linker settings > other linker settings I set:
pkg-config --libs gtk+-3.0
When compiling I got the next error in Build log:
Build file: "no target" in "no project" (compiler: unknown)
[ 50.0%] g++ -std=c++14 -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -c /home/meltdown/Documents/C++/GTKmm2019C/t1/t1.cpp -o /home/meltdown/Documents/C++/GTKmm2019C/t1/t1.o
[100.0%] g++ -o /home/meltdown/Documents/C++/GTKmm2019C/t1/t1 /home/meltdown/Documents/C++/GTKmm2019C/t1/t1.o -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
/home/meltdown/Documents/C++/GTKmm2019C/t1/t1.cpp:2:10: fatal error: gtkmm/gtkmm.h: No such file or directory
2 | #include <gtkmm/gtkmm.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
I use a single .cpp file, not a Gtk+ project.
I've tried this and this but no luck. Does anyone know how to set up Code::Blocks and its compiler properly for gtkmm?
You've asked the IDE to search include directories for the GTK+ package with the command:
`pkg-config --cflags gtk+-3.0`
However, your program uses gtkmm, which is a layer on top of GTK+. You want to broaden the search to encompass the directories for gtkmm:
`pkg-config --cflags gtkmm-3.0`
(This replaces the current entry in the "other compiler options".) Similarly, you'll need to change, under "other linker settings", the library paths to:
`pkg-config --libs gtkmm-3.0`
I try to install magick R package but I get error:
g++ -std=gnu++11 -shared -L/path/apps/R/3.5.1-20180807-test/x86_64-linux-2.6-rhel6/lib64/R/lib -L/path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/lib -Wl,--exclude-libs,libz.a -Wl,--exclude-libs,libbz2.a -Wl,--exclude-libs,libcurl.a -Wl,--exclude-libs,libpcre.a -Wl,--as-needed -o magick.so RcppExports.o animation.o attributes.o base.o color.o composite.o config.o convolve.o device.o edit.o fonts.o options.o properties.o resize.o transformations.o -L/path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/lib/ /path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/lib/libcurl.a /path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/lib/libz.a -Wl,--exclude-libs,libz.a -Wl,--exclude-libs,libcurl.a -lidn -lssl -lcrypto -lldap -lrt -lcairo -L/path/apps/mysql/5.7.11/x86_64-linux-2.6-rhel6/lib -lmysqlclient -lpthread -lm -lrt -ldl -L/path/apps/R/static-zlib-gcc6.3/x86_64-linux-2.6-rhel6/lib -lxml2 -lz -lm -ldl -L/path/apps/V8/3.14/x86_64-linux-2.6-rhel6/lib64 -L/path/apps/openmpi/1.8.1/x86_64-linux-2.6-rhel6/gnu/lsf/lib -L/path/apps/imagemagick/7.0.7-8/x86_64-linux-2.6-rhel6/lib/pkgconfig -lMagick++-6.Q16 -L/path/apps/R/3.5.1-20180807-test/x86_64-linux-2.6-rhel6/lib64/R/lib -lR
/usr/bin/ld: cannot find -lMagick++-6.Q16
collect2: error: ld returned 1 exit status
make: *** [magick.so] Error 1
ERROR: compilation failed for package ‘magick’
My LIB_DIR and INCLUDE_DIR looks like that:
export LIB_DIR="$STATIC_LIB/lib/ $STATIC_LIB/lib/libcurl.a \
$STATIC_LIB/lib/libz.a -Wl,--exclude-libs,libz.a \
-Wl,--exclude-libs,libcurl.a -lidn -lssl -lcrypto -lldap -lrt \
-lcairo $MYSQL_LIBS $XML2_LIBS -L$V8_LIBS \
-L$MPI_HOME/lib \
-L/path/apps/imagemagick/7.0.7-8/x86_64-linux-2.6-rhel6/lib/pkgconfig"
export INCLUDE_DIR="$STATIC_LIB/include -I/usr/include/cairo \
-I/usr/include/pixman-1 -I/usr/include/freetype2 \
-I/usr/include/libpng12 \
-I$MPI_HOME/include \
-I/path/apps/imagemagick/7.0.7-8/x86_64-linux-2.6-rhel6/include/ImageMagick-7"
include contains:
ls /path/apps/imagemagick/7.0.7-8/x86_64-linux-2.6-rhel6/include/ImageMagick-7
Magick++ MagickCore Magick++.h MagickWand
I found this question but my lib directory contains similar set of files:
ls /path/apps/imagemagick/7.0.7-8/x86_64-linux-2.6-rhel6/lib/
ImageMagick-7.0.7 libMagickCore-7.Q16HDRI.so.4
libMagick++-7.Q16HDRI.a libMagickCore-7.Q16HDRI.so.4.0.0
libMagick++-7.Q16HDRI.la libMagickWand-7.Q16HDRI.a
libMagick++-7.Q16HDRI.so libMagickWand-7.Q16HDRI.la
libMagick++-7.Q16HDRI.so.3 libMagickWand-7.Q16HDRI.so
libMagick++-7.Q16HDRI.so.3.0.0 libMagickWand-7.Q16HDRI.so.4
libMagickCore-7.Q16HDRI.a libMagickWand-7.Q16HDRI.so.4.0.0
libMagickCore-7.Q16HDRI.la pkgconfig
libMagickCore-7.Q16HDRI.so
I'm using imagemagick 7 so why it still requires some flag/arg -lMagick++-6.Q16 from version 6?
If pkg-config and Magick++-config are not available, the magick package defaults to ImageMagick v6:
PKG_LIBS="-lMagick++-6.Q16"
So you will have to install version 6. In addition you might also report an issue asking to support version 7 in the case of a installation without pkg-config/Magick++-config.
Alternatively you can try to get pkg-config/Magick++-config working on your machine. If pkg-config/Magick++-config can be used, the flags provided from there are used directly.
I've finally managed to install magick. I compiled ImageMagick v6 from source and installed R package with following set of env variables:
STATIC_LIB="/path/static-zlib-gcc6.3"
IMAGEMAGICK_V6_HOME="/path/ImageMagick-6.9.10-10"
export LIB_DIR="$STATIC_LIB/lib/ \
-L$IMAGEMAGICK_V6_HOME/lib"
export INCLUDE_DIR="$STATIC_LIB/include \
-DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 \
-I$IMAGEMAGICK_V6_HOME/include/ImageMagick-6"
export PKG_CONFIG_PATH="$IMAGEMAGICK_V6_HOME/lib/pkgconfig/:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$IMAGEMAGICK_V6_HOME/lib:$LD_LIBRARY_PATH"
I have been trying to get wxWidgets working on Cygwin. So far I have had success by using a mingw compiler available through the cygwin installer.
The build seemed to work fine. The configure message I used was:
configure --host=i686-w64-mingw32 --build=i686-pc-cygwin --enable-static --disable-shared
After that I ran a make and make install and got no errors.
Next I grabbed an example from a tutorial and ran:
i686-w64-mingw32-g++ -c -o hello_world.o hello_world.cpp CXX_FLAGS
i686-w64-mingw32-g++ -o a hello_world.o CXX_FLAGS LIBS
where CXX_FLAGS and LIBS are generated from wx-config -cxxflags and wx-config --libs. This works fine, but when I try to run the executable I get this error:
C:/Users/sam/Documents/cpp/wxwidgets_tutorial/a.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
The libraries I build should be static, so I'm not sure what to do with this message. Any help is greatly appreciated!
Some more info:
wx-config --cxxflags gives the output:
-I/usr/local/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.0 -I/usr/local/include/wx-3.0 -D_FILE_OFFSET_BITS=64 -D__WXMSW__ -mthreads
wx-config --libs give the output:
-L/usr/local/lib -Wl,--subsystem,windows -mwindows /usr/local/lib/libwx_mswu_xrc-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_webview-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_qa-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_baseu_net-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_html-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_adv-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_mswu_core-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_baseu_xml-3.0-i686-w64-mingw32.a /usr/local/lib/libwx_baseu-3.0-i686-w64-mingw32.a -lpng -ljpeg -ltiff -lexpat -lwxregexu-3.0-i686-w64-mingw32 -lz -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32
ls /usr/local/lib:
libwx_baseu_net-3.0-i686-w64-mingw32.a
libwx_baseu_xml-3.0-i686-w64-mingw32.a
libwx_baseu-3.0-i686-w64-mingw32.a
libwx_mswu_adv-3.0-i686-w64-mingw32.a
libwx_mswu_aui-3.0-i686-w64-mingw32.a
libwx_mswu_core-3.0-i686-w64-mingw32.a
libwx_mswu_gl-3.0-i686-w64-mingw32.a
libwx_mswu_html-3.0-i686-w64-mingw32.a
libwx_mswu_media-3.0-i686-w64-mingw32.a
libwx_mswu_propgrid-3.0-i686-w64-mingw32.a
libwx_mswu_qa-3.0-i686-w64-mingw32.a
libwx_mswu_ribbon-3.0-i686-w64-mingw32.a
libwx_mswu_richtext-3.0-i686-w64-mingw32.a
libwx_mswu_stc-3.0-i686-w64-mingw32.a
libwx_mswu_webview-3.0-i686-w64-mingw32.a
libwx_mswu_xrc-3.0-i686-w64-mingw32.a
libwxregexu-3.0-i686-w64-mingw32.a
libwxscintilla-3.0-i686-w64-mingw32.a
wx
EDIT:
Following VZ's advise, I added /usr/i686-w64-mingw32/sys-root/mingw/bin to my path... It compiles!
However when run, the program does not open any window, just exits immediately. Is this still a library problem?
You need to copy the required DLLs (at least libstdc++-6.dll and libgcc_s_sjlj-1.dll) from /usr/i686-w64-mingw32/sys-root/mingw/bin to a directory in your PATH or the application directory (or add this directory itself to your PATH, of course).
You can use cygcheck or (native) dependency walker tool to find which DLL is actually missing.
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
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!