GTK+ compile in Bloodshed Dev-C++ compiler error - c

I'm trying to compile a C program using GTK+ in bloodshed Dev-C++ 4.9.9.2.
I've added all the include files in the compiler options plus all compiler options, but I get the following error:
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Projects\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Projects\Makefile.win" all
gcc.exe main.o -o "MyCProject.exe" -L"C:/Dev-Cpp/lib" -lgtk-win32-2.0 -lgdk-win32-2.0 -limm32 -lshell32 -lole32 -latk-1.0 -lgdk_pixbuf-2.0 -lcairo -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lm -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -lfreetype -lzdll -lfontconfig -lpng13 -lpangocairo-1.0
C:\Dev-Cpp\Bin..\lib\gcc\mingw32\3.4.2........\mingw32\bin\ld.exe: cannot find -lintl
collect2: ld returned 1 exit status
make.exe: *** [MyCProject.exe] Error 1
Execution terminated
Can someone help me with what '-lintl' is and if it's a package missing or some file?

LibIntl
http://gnuwin32.sourceforge.net/packages/libintl.htm
You can get devpak from HERE
Aside:
I don't think Dev-C++ has been updated in years. Have you considered moving to Code::Blocks

Related

Gtk+-3.0 seems work well in mingw64, however, the gcc build the code fail due to some undefined reference to issue

System: Win10 + Mysy64 + mingw64 + gtk+3.0
When I checked that below are ok as shown below, it seems work well.
pkg-config --cflags gtk+-3.0
C:\msys64>pkg-config --cflags gtk+-3.0
-IC:/msys64/mingw64/bin/../include/gtk-3.0 -IC:/msys64/mingw64/bin/../include/pango-1.0 -IC:/msys64/mingw64/bin/../include -IC:/msys64/mingw64/bin/../include/glib-2.0 -IC:/msys64/mingw64/bin/../lib/glib-2.0/include -IC:/msys64/mingw64/bin/../include/harfbuzz -IC:/msys64/mingw64/bin/../include/freetype2 -IC:/msys64/mingw64/bin/../include/libpng16 -IC:/msys64/mingw64/bin/../include/fribidi -IC:/msys64/mingw64/bin/../include/cairo -IC:/msys64/mingw64/bin/../include/lzo -IC:/msys64/mingw64/bin/../include/pixman-1 -IC:/msys64/mingw64/bin/../include/gdk-pixbuf-2.0 -IC:/msys64/mingw64/bin/../include/atk-1.0 -mms-bitfields
pkg-config --libs gtk+-3.0
C:\msys64>pkg-config --libs gtk+-3.0
-LC:/msys64/mingw64/bin/../lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lhid -lwinspool -lcomctl32 -lcomdlg32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
When I try to build below code, errors shown, may I know how to fix it, thank you.
#include <gtk/gtk.h>
int main() {
gtk_init(NULL, NULL);
return 0;
}
Build command in code::blocks:
gcc.exe -LC:\msys64\mingw64 -o bin\Debug\gtk.exe obj\Debug\main.o -LC:/msys64/mingw64/bin/../lib -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lhid -lwinspool -lcomctl32 -lcomdlg32 -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
||=== Build: Debug in gtk (compiler: GNU GCC Compiler) ===|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c|| undefined reference to `__mingw_init_ehandler'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c|| undefined reference to `__security_init_cookie'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c|| undefined reference to `__security_init_cookie'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_app_type[.refptr.mingw_app_type]+0x0)||undefined reference to `mingw_app_type'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initcharmax[.refptr.mingw_initcharmax]+0x0)||undefined reference to `mingw_initcharmax'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltssuo_force[.refptr.mingw_initltssuo_force]+0x0)||undefined reference to `mingw_initltssuo_force'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdyn_force[.refptr.mingw_initltsdyn_force]+0x0)||undefined reference to `mingw_initltsdyn_force'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\lib\..\lib\crt2.o:crtexe.c:(.rdata$.refptr.mingw_initltsdrot_force[.refptr.mingw_initltsdrot_force]+0x0)||undefined reference to `mingw_initltsdrot_force'|
||error: ld returned 1 exit status|
||=== Build failed: 9 error(s), 0 warning(s) (0 minute(s), 5 second(s)) ===|
The build command is generated in code::blocks.
In code::blocks, I set pkg-config --cflags gtk+-3.0 under Compiler setting -> Other compiler options, and pkg-config --libs gtk+-3.0 under Linker setting -> Other linker options. so the build command is combined by these two flags.

How to build GTK+ APP for ARM based of Linux platform

Could you help to solve this problem?
I am trying to cross-compile a sample GTK+ application for freescale i.MX-6 arm based processor
i have exported my Toolchain path
**export PATH=/u02/tools/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin:$PATH**
and i am trying to cross-compile the application by using following sequence
**arm-none-linux-gnueabi-gcc gtk-frameless.c -o frameless `pkg-config --cflags=-I/U02/tools/DOP/imx6/rootfs/usr/include gtk+-2.0` `pkg-config --libs=-L/U02/tools/DOP/imx6/rootfs/usr/lib/ -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lglib-2.0 -lfreetype`**
and i am stuck with the following error
**-lgtk-x11-2.0: unknown option
/tmp/ccn3JmIw.o: In function main':
gtk-frameless.c:(.text+0x24): undefined reference togtk_init'
gtk-frameless.c:(.text+0x2c): undefined reference to `gtk_window_new'
gtk-frameless.c:(.text+0x38): undefined reference to `gtk_widget_show'
gtk-frameless.c:(.text+0x3c): undefined reference to `gtk_main'
collect2: ld returned 1 exit status**
in my case i guess i was unable to specify the path of the libraries correctly..?
Is my guess correct or apart from that am i doing any thing wrong,please guide me, to make it compile or provide links of related documents,so that i can try myself.
Any thing would be helpful.
Thankyou
i guess i was unable to specify the path of the libraries correctly..?
Yup. Take a close look at the actual flags you pass. These calls do not actually work (try them and see the results):
pkg-config --cflags=-I/U02/tools/DOP/imx6/rootfs/usr/include gtk+-2.0
pkg-config --libs=-L/U02/tools/DOP/imx6/rootfs/usr/lib/ -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfontconfig -lgobject-2.0 -lglib-2.0 -lfreetype
You've got two basic options: either you use pkg-config like this
pkg-config --cflags gtk+-2.0
pkg-config --libs gtk+-2.0
which gives you the libraries and headers that your pkg-config knows about...
Or you construct the includes and linker flags by hand to point to the cross-compile target header and library locations.
If you're lucky you may be able to use PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_LIBDIR env variables to enable the use of pkg-config even for cross-compiling (see pkg-config documentation). Some cross-development environments (say, Yocto/openembedded) will do this for you.

How to use GTK C library?

I'm new at C and started to learn how to create GUI.
For some reason the only way program run is
gcc simple.c -o simple -lgtk-3 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 -pthread -I/usr/include/gtk-3.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/pixman-1 -I/usr/include/libpng12
If i just run gcc simple.cit gives me
In file included from /usr/include/glib-2.0/glib/galloca.h:32:0,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/glib-2.0/gobject/gbinding.h:28,
from /usr/include/glib-2.0/glib-object.h:23,
from /usr/include/glib-2.0/gio/gioenums.h:28,
from /usr/include/glib-2.0/gio/giotypes.h:28,
from /usr/include/glib-2.0/gio/gio.h:26,
from /usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:30,
from /usr/include/gtk-2.0/gdk/gdk.h:32,
from /usr/include/gtk-2.0/gtk/gtk.h:32,
from graphical.c:1:/usr/include/glib-2.0/glib/gtypes.h:32:24: fatal error: glibconfig.h: No such file or catalog compilation terminated.
If I do other 'traditional' ways to include lib:
gcc `pkg-config gtk+-2.0 --cflags` example.c -o example `pkg-config gtk+-2.0 --libs`
It gives me:
Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
graphical.c:1:21: fatal error: gtk/gtk.h: No such file or catalog
What is the right way to include GTK?
I just figured out what was the problem.
I had linuxbrew installed and for some reason pkg-config took path from one of it's repos even if I force it to export.
I completely removed linuxbrew and now it's finally working!

ld complains: in function "_start", undefined reference to "__libc_csu_fini" & "__libc_csu_init"

I'm compiled a GTK+ program using clang, rather than gcc. So far so good, except I can't have ld link correctly.
Original makefile called gcc to do the linking, like this:
gcc -g -O2 -export-dynamic -o my_application somefile.o another.o -pthread -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomevfs-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lart_lgpl_2 -lgconf-2 -lglade-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lxml2 -pthread -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0
If I simply substitute gcc with clang in the above command, I get this warning from the latter:
clang: warning: argument unused during compilation: '-e xport-dynamic'
Problem is: clang doesn't recognize "-export-dynamic" as a linker option, so it doesn't pass it off to ld. This causes the references to external functions to be scrapped: when final binary is executed, neither the menu options nor the buttons react.
If I do final linking step with gcc the binary works perfectly (even though it was really compiled with clang and gcc only does the linking). Since I'm trying to completely replace gcc with clang in my machine, this is not acceptable.
So I tried this:
ld /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o -g -O2 -export-dynamic my_application somefile.o another.o -o -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomevfs-2 -lgnomecanvas-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lart_lgpl_2 -lgconf-2 -lglade-2.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lxml2 -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lxml2 -lgthread-2.0 -lrt -lglib-2.0
By adding first 3 objects I avoid the "can't find _start" message. But then I get the aforementioned two complaints:
/usr/lib/crt1.o: In function _start:
(.text+0x12): undefined reference to __libc_csu_fini
/usr/lib/crt1.o: In function _start:
(.text+0x19): undefined reference to __libc_csu_init
I tried adding crtbegin.o and crtend.o at the list, even before crt1.o , to no avail. What is the linker's correct invocation?
(Post Edit): If nothing else works, is there a way to catch what exact parameters gcc is passing to ld when gcc is used for the linking?
gcc automatically adds language support libraries and objects to your supplied list for link. You have to add them yourself if you want to invoke ld directly. Taking an example from man ld, it could be
ld -o <output> /lib/crt0.o hello.o -lc
Try adding -lc, the symbol you need should be in it (at least on my system, it is).
You can use -Wl,-export-dynamic to pass -export-dynamic to ld without clang knowing about it.

Linking issue with dev-c++ on Windows

I'm taking over a C++ project developed with Dev-C++ (yeah, I know...): it compiles fine but it won't link and the error message is not very indicative:
Compiler: Default compiler
Building Makefile: "S:\Spirale 2\spiral2\conditionnement\trunk2011\Makefile.win"
Finding dependencies for file: S:\Spirale 2\spiral2\conditionnement\trunk2011\spirale2.cpp
Finding dependencies for file: S:\Spirale 2\spiral2\conditionnement\trunk2011\sp_pulse.cpp
Finding dependencies for file: S:\Spirale 2\spiral2\conditionnement\trunk2011\sp_cb.cpp
Finding dependencies for file: S:\Spirale 2\spiral2\conditionnement\trunk2011\sp_daq.cpp
Finding dependencies for file: S:\Spirale 2\spiral2\conditionnement\trunk2011\sp_rs232.c
Executing make...
make.exe -f "S:\Spirale 2\spiral2\conditionnement\trunk2011\Makefile.win" all
g++.exe -D__DEBUG__ obj/spirale2.o obj/sp_pulse.o obj/sp_cb.o obj/sp_daq.o obj/sp_rs232.o obj/Spirale2_private.res -o "Spirale2.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/gtk+-bundle_2.22.1-20101227_win32/bin" -L"C:/RSSI/lib/msc" -L"C:/RSSI/lib/bc" -L"C:/Dev-Cpp/gtk+-bundle_2.22.1-20101227_win32/lib" -L"C:/Dev-Cpp/libiconv-1.9.1.bin.woe32/lib" -mwindows -lgtk-win32-2.0 -lgdk-win32-2.0 -lgthread-2.0 -lgdi32 -lole32 -luuid -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -liconv -lrssism -g3
obj/spirale2.o: could not read symbols: Invalid argument
collect2: ld returned 1 exit status
make.exe: *** [Spirale2.exe] Error 1
Execution terminated
I broke down the last instruction to the linker here (one line per option for readability) and ran it from the command line:
c:/Dev-Cpp/libexec/gcc/mingw32/3.4.2/collect2.exe
--subsystem windows
-Bdynamic
-o Spirale2.exe
c:/Dev-Cpp/lib/crt2.o
c:/Dev-Cpp/lib/gcc/mingw32/3.4.2/crtbegin.o
-LC:/Dev-Cpp/lib
-LC:/Dev-Cpp/gtk+-bundle_2.22.1-20101227_win32/bin
-LC:/RSSI/lib/msc
-LC:/RSSI/lib/bc
-LC:/Dev-Cpp/gtk+-bundle_2.22.1-20101227_win32/lib
-LC:/Dev-Cpp/libiconv-1.9.1.bin.woe32/lib
-Lc:/Dev-Cpp/lib/gcc/mingw32/3.4.2
-Lc:/Dev-Cpp/lib/gcc
-Lc:/Dev-Cpp/mingw32/lib
-Lc:/Dev-Cpp/lib
obj/spirale2.o
obj/sp_pulse.o
obj/sp_cb.o
obj/sp_daq.o
obj/sp_rs232.o
obj/Spirale2_private.res
-lgtk-win32-2.0
-lgdk-win32-2.0
-lgthread-2.0
-lgdi32
-lole32
-luuid
-latk-1.0
-lgdk_pixbuf-2.0
-lpangowin32-1.0
-lgdi32
-lpango-1.0
-lgobject-2.0
-lgmodule-2.0
-lglib-2.0
-lintl
-liconv
-lrssism
-lstdc++
-lmingw32
-lgcc
-lmoldname
-lmingwex
-lmsvcrt
-lgdi32
-lcomdlg32
-luser32
-lkernel32
-ladvapi32
-lshell32
-lmingw32
-lgcc
-lmoldname
-lmingwex
-lmsvcrt
c:/Dev-Cpp/lib/gcc/mingw32/3.4.2/crtend.o
obj/spirale2.o: could not read symbols: Invalid argument
collect2: ld returned 1 exit status
I thought it might have been a file with the wrong CPU architecture, but I've checked the .o files:
crt2.o: 80386 COFF executable not stripped - version 30821
crtbegin.o: 80386 COFF executable not stripped - version 30821
crtend.o: 80386 COFF executable not stripped - version 30821
sp_cb.o: 80386 COFF executable not stripped - version 30821
sp_daq.o: 80386 COFF executable not stripped - version 30821
spirale2.o: 80386 COFF executable not stripped - version 30821
sp_pulse.o: 80386 COFF executable not stripped - version 30821
sp_rs232.o: 80386 COFF executable not stripped - version 30821
Any idea ? Thanks.
Like I said, the project is old and only needs a few modifications, so I don't really want to upgrade everything !

Resources