Cannot build gtk on windows - gtk

I have an installation of minGW which works well for building straightfowrd C++ programs.
Now I am installing GTK, following the instructions here: http://www.gtk.org/download/win32_tutorial.php
I have grabbed a GTK hellow world program from here: https://developer.gnome.org/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD
but when I try to build it, using this command
C:\Users\James\code\smartone>gcc -o hello.exe gtk_hello_world.c -mms-bitfields
IC:/gtk/include/gtk-3.0 -IC:/gtk/include/cairo -IC:/gtk/include/pango-1.0 -IC:/
tk/include/atk-1.0 -IC:/gtk/include/cairo -IC:/gtk/include/pixman-1 -IC:/gtk/in
lude -IC:/gtk/include/freetype2 -IC:/gtk/include -IC:/gtk/include/libpng15 -IC:
gtk/include/gdk-pixbuf-2.0 -IC:/gtk/include/libpng15 -IC:/gtk/include/glib-2.0
IC:/gtk/lib/glib-2.0/include -LC:/gtk/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshe
l32 -lole32 -Wl,-luuid -lpangocairo-1.0 -lpangoft2-1.0 -lfreetype -lfontconfig
lpangowin32-1.0 -lgdi32 -lpango-1.0 -lm -latk-1.0 -lcairo-gobject -lcairo -lgdk
pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
I get these errors
c:/mingw/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mi
ngw32/bin/ld.exe: skipping incompatible C:/gtk/lib/libgtk-3.dll.a when searching
for -lgtk-3
c:/mingw/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mi
ngw32/bin/ld.exe: skipping incompatible C:/gtk/lib/libgtk-3.dll.a when searching
for -lgtk-3
c:/mingw/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mi
ngw32/bin/ld.exe: cannot find -lgtk-3
... etc, etc, etc
What have I missed?

You are using a 64 bits compiler. Build with your 64 bits compiler in 32 bits mode with gcc's -m32 option.

Related

platformIO does not show binary sizes on build

I am using VsCode with PlatformIO with a very simple program.
It compiles correctly and produces working elf and hex files.
However, unless pio states that it checkes the sizes it does not output anything.
my configuration is the following
[env:release]
platform = atmelavr
board_build.mcu = atmega168A
board_build.f_cpu = 8000000L
running the build it just outputs:
Processing release (platform: atmelavr)
----------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
HARDWARE: ATMEGA168A 8MHz,
PACKAGES:
- toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> [had to replace link to being allowed to post]
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\release\src\HMI.o
Compiling .pio\build\release\src\Oled.o
Compiling .pio\build\release\src\Segment.o
Compiling .pio\build\release\src\main.o
Linking .pio\build\release\firmware.elf
Checking size .pio\build\release\firmware.elf
Building .pio\build\release\firmware.hex
=========================================================== [SUCCESS] Took 1.95 seconds ===========================================================
even with running it with -v it shows not much more information
Processing release (platform: atmelavr; board_build.mcu: atmega168A; board_build.f_cpu: 8000000L)
----------------------------------------------------------------------------------------------------------------------------------------------------HARDWARE: ATMEGA168A 8MHz,
PACKAGES:
- toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> [had to replace link to being allowed to post]
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
avr-gcc -o .pio\build\release\src\HMI.o -c -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega168A -DF_CPU=8000000L -DPLATFORMIO=50101 -Isrc src\HMI.c
avr-gcc -o .pio\build\release\src\Oled.o -c -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega168A -DF_CPU=8000000L -DPLATFORMIO=50101 -Isrc src\Oled.c
avr-gcc -o .pio\build\release\src\Segment.o -c -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega168A
-DF_CPU=8000000L -DPLATFORMIO=50101 -Isrc src\Segment.c
avr-gcc -o .pio\build\release\src\main.o -c -std=gnu11 -fno-fat-lto-objects -Os -Wall -ffunction-sections -fdata-sections -flto -mmcu=atmega168A -DF_CPU=8000000L -DPLATFORMIO=50101 -Isrc src\main.c
avr-gcc -o .pio\build\release\firmware.elf -Os -mmcu=atmega168A -Wl,--gc-sections -flto -fuse-linker-plugin .pio\build\release\src\HMI.o .pio\build\release\src\Oled.o .pio\build\release\src\Segment.o .pio\build\release\src\main.o -L.pio\build\release -Wl,--start-group -lm -Wl,--end-group
MethodWrapper(["checkprogsize"], [".pio\build\release\firmware.elf"])
avr-objcopy -O ihex -R .eeprom .pio\build\release\firmware.elf .pio\build\release\firmware.hex
=========================================================== [SUCCESS] Took 1.77 seconds ===========================================================
I am using
PIO extension v2.3.2
PIO Core 5.1.1·Home 3.3.4
platform atmelavr at 3.3.0
Manually calling avr-size from the the downloaded packages correctly shows the info.
Any suggestions how to solve this?
Adding an explicit board config item to the config seems to fix that problem.
[env:release]
platform = atmelavr
board = ATmega168
board_build.mcu = atmega168A
board_build.f_cpu = 8000000L

linking problem, can't find symbol even though nm shows symbol in library

I'm linking an app against lflutter_linux_glfw. nm tools shows it has glad_glTexImage2D:
nm libflutter_linux_glfw.so | grep glTexImage2D
00000000034e87a0 b glad_glTexImage2D
00000000034e87a8 b glad_glTexImage2DMultisample
So I included lflutter_linux_glfw.so before flutter_video_renderer.o, and I get this:
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Candidate multilib: .;#m64
Selected multilib: .;#m64
"/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /home/dev/orwell/orwell_flutter/linux/../build/linux/debug/flutter_desktop_example
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/crtbegin.o
-L/home/dev/orwell/orwell_flutter/linux/../build/linux/debug/lib -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu
-L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../.. -L/usr/lib/llvm-6.0/bin/../lib -L/lib -L/usr/lib -lflutter_linux_glfw
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj/main.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/flutter/generated_plugin_registrant.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/flutter_window_controller.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/plugin_registrar.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/engine_method_result.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/standard_codec.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_video_renderer.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_texture_video_renderer.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_orwell_plugin.o "-rpath=\$ORIGIN/lib" -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crtn.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_texture_video_renderer.o: In function
`flutter_orwell_plugin::FlutterTextureVideoRenderer::renderToTexture(unsigned long, unsigned long, unsigned int)':
flutter_texture_video_renderer.cc:(.text+0x1b6): undefined reference to `glad_glTexImage2D'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/dev/orwell/orwell_flutter/linux/../build/linux/debug/flutter_desktop_example] Error 1
In other words, it complains there's no reference to glad_glTexImage2D even though it it indeed in
flutter_linux_glfw.so. I also tried adding flutter_linux_glfw.so after the flutter_texture_video_renderer.o but I get the same error
nm libflutter_linux_glfw.so | grep glTexImage2D
00000000034e87a0 b glad_glTexImage2D
00000000034e87a8 b glad_glTexImage2DMultisample
These symbols are local to the library (not exported from it).
You can see the list of exported symbols with:
nm -D libflutter_linux_glfw.so
You will observe that glad_glTexImage2D is not listed there.
P.S.
I included lflutter_linux_glfw.so before flutter_video_renderer.o
This is the opposite order of what you are supposed to do: libraries should follow the objects that refer to them (though this doesn't really matter for shared libraries).

Error on running Inline::C

Tried to run Inline::C on windows 7 (using active perl 5.14), got some errors. Not sure where to install the library "bufferoverflowU". Is it really needed?
perl te.pl
Set up gcc environment - 4.8.2
C:\Perl64\bin\perl.exe C:\Perl64\lib\ExtUtils\xsubpp -typemap "C:\Perl64\lib\ExtUtils\typemap" te1_pl_1114.xs > te1_pl_1114.xsc && C:\Perl64\bin\perl.exe -MExtUtils::Command -e "mv" -- te1_pl_1114.xsc te1_pl_1114.c
c:/WINBUI~1/bin/gcc.exe -c -I"C:/winbuild64/test" -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DHASATTRIBUTE -fno-strict-aliasing -mms-bitfields -O2 -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" "-IC:\Perl64\lib\CORE" te1_pl_1114.c
Running Mkbootstrap for te1_pl_1114 ()
C:\Perl64\bin\perl.exe -MExtUtils::Command -e "chmod" -- 644 te1_pl_1114.bs
C:\Perl64\bin\perl.exe -MExtUtils::Mksymlists \
-e "Mksymlists('NAME'=>\"te1_pl_1114\", 'DLBASE' => 'te1_pl_1114', 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);"
Set up gcc environment - 4.8.2
dlltool --def te1_pl_1114.def --output-exp dll.exp
c:\WINBUI~1\bin\g++.exe -o blib\arch\auto\te1_pl_1114\te1_pl_1114.dll -Wl,--base-file -Wl,dll.base -mdll -L"C:\Perl64\lib\CORE" te1_pl_1114.o C:\Perl64\lib\CORE\perl514.lib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 -lbufferoverflowU -lmsvcrt dll.exp
c:/winbui~1/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lbufferoverflowU
collect2.exe: error: ld returned 1 exit status
dmake.exe: Error code 129, while making 'blib\arch\auto\te1_pl_1114\te1_pl_1114.dll'
A problem was encountered while attempting to compile and install your Inline
C code. The command that failed was:
C:\Perl64\site\bin\dmake.exe > out.make 2>&1
The build directory was:
C:\winbuild64\test\_Inline\build\te1_pl_1114
To debug the problem, cd to the build directory, and inspect the output files.
at te1.pl line 6
...propagated at C:/Perl64/site/lib/Inline/C.pm line 798.
BEGIN failed--compilation aborted at te1.pl line 6.
The perl file is very simple
use Inline C => <<'END_C';
void greet() {
printf("Hello, world\n");
}
END_C
greet;
bufferoverflowU is not a Perl library. It's part of the Windows SDK, though is not included in recent versions. At a guess, you're using ActivePerl, and installed Inline::C using their PPM. Their copy of Inline::C will have been built against whatever version of the Windows SDK they have on their build machines. But you seem to have a newer SDK on your machine.
You could try downloading the latest Inline::C tarball and building it on your own machine. This will hopefully replace your old copy of Inline::C, and hopefully work.

GTK build missing include file gdk-pixbuf/gdk-pixbuf.h

I have installed GTK, following the instructions here: http://www.gtk.org/download/win32_tutorial.php
Now I am trying to build a GTK hello world program from here: https://developer.gnome.org/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD
I hit this error:
In file included from C:/gtk/include/gtk-3.0/gdk/gdkcairo.h:28:0,
from C:/gtk/include/gtk-3.0/gdk/gdk.h:33,
from C:/gtk/include/gtk-3.0/gtk/gtk.h:30,
from gtk_hello_world.c:1:
C:/gtk/include/gtk-3.0/gdk/gdkpixbuf.h:34:35: fatal error: gdk-pixbuf/gdk-pixbuf
.h: No such file or directory
#include <gdk-pixbuf/gdk-pixbuf.h>
^
This seems to be the same problem as How to repair "error: gdk-pixbuf/gdk-pixdata.h: No such file or directory?" but I do not understand the answer to that question.
Here is the command line to the compiler
C:\Users\James\code\smartone>gcc -o hello.exe gtk_hello_world.c -m32 -mms-bitfie
lds -IC:/gtk/include/gtk-3.0 -IC:/gtk/include/cairo -IC:/gtk/include/pango-1.0 -
IC:/tk/include/atk-1.0 -IC:/gtk/include/cairo -IC:/gtk/include/pixman-1 -IC:/gtk
/inlude -IC:/gtk/include/freetype2 -IC:/gtk/include -IC:/gtk/include/libpng15 -I
C:/gtk/include/libpng15 -IC:/gtk/include/glib-2.0 -IC:/gtk/lib/glib-2.0/include
-LC:/gtk/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshel32 -lole32 -Wl,-luuid -lpango
cairo-1.0 -lpangoft2-1.0 -lfreetype -lfontconfig -lpangowin32-1.0 -lgdi32 -lpang
o-1.0 -lm -latk-1.0 -lcairo-gobject -lcairo -lgdkpixbuf-2.0 -lgio-2.0 -lgobject-
2.0 -lglib-2.0
This was mostly generated using
pkg-config --cflags --libs gtk+-3.0
-mms-bitfields -IC:/gtk/include/gtk-3.0 -IC:/gtk/include/cairo -IC:/gtk/include/
pango-1.0 -IC:/gtk/include/atk-1.0 -IC:/gtk/include/cairo -IC:/gtk/include/pixma
n-1 -IC:/gtk/include -IC:/gtk/include/freetype2 -IC:/gtk/include -IC:/gtk/includ
e/libpng15 -IC:/gtk/include/gdk-pixbuf-2.0 -IC:/gtk/include/libpng15 -IC:/gtk/in
clude/glib-2.0 -IC:/gtk/lib/glib-2.0/include -LC:/gtk/lib -lgtk-3 -lgdk-3 -lgdi3
2 -limm32 -lshell32 -lole32 -Wl,-luuid -lpangocairo-1.0 -lpangoft2-1.0 -lfreetyp
e -lfontconfig -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lm -latk-1.0 -lcairo-gobjec
t -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl
I know this question is extremely old, but I ran into this error while compiling xscreensaver from source on Debian Stretch and found that the missing package was libglade2-dev, despite all intuition that might suggest it is libgdk-pixbuf2.0-dev
Hope this might help the next guy looking for an answer to this one.
We need the exact gcc command line that caused the error. If the file is not found, it's because pkg-config couldn't pass to gcc the right location of your gdk-pixbuf installation.
First run pkg-config --list-all | grep gdk-pixbuf to get the exact name of the gdk-pixbuf module on you machine (for me it's gdk-pixbuf-2.0). The use that name, to check what directory pkg-config thinks gdk-pixbuf is installed:
pkg-config --cflags gdk-pixbuf-2.0
returns for me:
-pthread -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng15 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
The -I tells here to gcc to include directory /usr/include/gdk-pixbuf-2.0. And this is where your file are not.

Cross Compile perl for ARM

I'm attempting to cross compile the perl interpreter for an ARM architecture (FriendlyARM Micro2440). I'm using the ARM-Linux GCC 4.4.3 cross-compiler provided by the manufacturer. The board is running Linux 2.6.
I was able to cross-compile a basic "Hello World" application successfully, and it ran on the target machine.
I've downloaded the perl v5.12.3 source. I was able to do a normal compilation of perl for Ubuntu. I'm now attempting to do a cross-compilation for the ARM board. I'm working out of the perl-5.12.3/Cross folder in the source download.
make patch succeeded, but when I run make perl it fails with this
LD_LIBRARY_PATH=/home/reed022/.local/share/Trash/files/perl-5.2.12.3 arm-linux-gcc -o miniperl \
gv.o toke.o perly.o pad.o regcomp.o dump.o util.o mg.o reentr.o mro.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o universal.o globals.o perlio.o perlapi.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o \
miniperlmain.o opmini.o perlmini.o -lnsl -ldl -lm -lcrypt -lutil -lc
LD_LIBRARY_PATH=/home/reed022/.local/share/Trash/files/perl-5.2.12.3 ./miniperl -w -Ilib -MExporter -e '<?>' || make minitest
./miniperl: 1: Syntax error: word unexpected (expecting ")")
I think the relevant part of the output is the ./miniperl -w -Ilib -MExporter -e '<?>' || make minitest part. Though I'm not sure. It seems confusing to me that the cross-compilation environment would try to run tests, since it's targeting a different system than the one it's being built on.
I'm completely lost as where to go from here. The people I've talked to haven't had much experience with cross-compiling programs.
UPDATE
I decided to delete the perl source folder and re-extract it, thinking that the previous compilation of perl for the Ubuntu host machine might have been messing with the current cross-compilation. I'm now getting a different but similar error.
`sh cflags "optimize='-O2'" generate_uudmap.o` -fexpensive-optimizations -fomit-frame-pointer -O2 -march=armv4 -mtune=strongarm1100 generate_uudmap.c
CCCMD = arm-linux-gcc -DPERL_CORE -c -fexpensive-optimizations -fomit-frame-pointer -O2 -march=armv4 -mtune=strongarm1100 -O2 -Wall
arm-linux-gcc -o generate_uudmap generate_uudmap.o -lnsl -ldl -lm -lcrypt -lutil -lc
./generate_uudmap uudmap.h bitcount.h
./generate_uudmap: 1: Syntax error: word unexpected (expecting ")")
make[1]: *** [bitcount.h] Error 2
make[1]: Leaving directory `/home/reed022/Downloads/perl-5.12.3'
make[1]: Entering directory `/home/reed022/Downloads/perl-5.12.3'
make[1]: *** No rule to make target `more'. Stop.
make[1]: Leaving directory `/home/reed022/Downloads/perl-5.12.3'
make: *** [perl] Error 2
Apparently the way to cross compile perl is not to do it under the Cross directory. I needed to pass flags to Configure to set it up. I also needed to setup the ARM computer with an SSH server (I used dropbear). The flags I used are
sh ./Configure
-Dusecrosscompile
-Dtargethost=<IP of ARM computer>
-Dtargetuser=<user name>
-Dtargetarch=arm-linux
-Dcc=arm-linux-gcc
-Dusrinc=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/include/
-Dincpth=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/include/
-Dlibpth=/opt/FriendlyARM/toolschain/4.4.3/lib
-Dtargetdir=/sdcard/perl
The easiest way to cross-compile perl for arm is to use perl-cross.
Alex Suykov developed a set of patches for perl that works around the requirement to have a target machine available. Part of the solution is avoiding make test since the host can't run cross-compiled code anyway.
I used arm-unknown-linux-uclibcgnueabi as my target (to match my buildroot toolchain), but otherwise the directions for perl 5.18.0 worked just fine.
Alex last updated the github repository on April 23, 2014, so this project is still relatively active.