Static cross-compilation of GTK applications on Fedora for Windows? - gcc

I'm trying to build gtk3 applications for windows and since Fedora delivers mingw and precompiled libraries for gtk3 for mingw, I used it.
I got the normal compilation working via
i686-mingw32-gcc test.c `pkg-config --cflags --libs gtk+-win32-3.0`
Now I would like to link it statically (Fedora delivers precompiled libraries for that too) but i cannot get it to work. It tryed
i686-mingw32-gcc test.c -static `pkg-config --cflags --libs --static gtk+-win32-3.0`
but it results in
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lgtk-3
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lgdk-3
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lgdk_pixbuf-2.0
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lpng14
/usr/lib/gcc/i686-pc-mingw32/4.6.1/../../../../i686-pc-mingw32/bin/ld: cannot find -lffi

AFAIK, static compilation is not supported for GTK+. Anyway, gcc arguments order is important for building with mingw.

Related

How to configure GNU Autotools to compile a program in 32-bit while on Centos7?

I'm doing all this on a VLE and below is what I'm working with:
Running OS: Linux Centos 7
GCC:4.8.5 & 7.1.0
I'm trying to use GNU autotools (libtool, autoconf, automake) to build a project in 32-bit using gcc-7.1.0. Also, as a requirement, I must do this on Centos 7 and use gcc-7.1.0.
Apparently, the latest version of gcc that can be officially upgraded through yum is 4.8.5. However, I successfully installed gcc-7.1.0 from the official source and even included --enable-multiarch --with-list-multilib=m32,m64 --enable-multilib during configure.
The issue I'm running into is that the autotools seem to want to use the 64-bit libraries even though I'm including -m32 compiler switch in CXXFLAGS, CFLAGS, and LDFLAGS. The reason I think it's using 64-bit libraries at linking is that I get the error below:
libtool: link: g++ -m32 -fPIC -Wall -Wextra -Weffc++ -Werror -std=c++03 -O2 -o fldprog fldprog-icpprog.o ../../ ../seal3/fld/src/.libs/libbsp_fld.a -lpci /usr/local/lib/../lib64/libstdc++.so -lm -Wl,-rpath -Wl,/usr/local/lib /../lib64 -Wl,-rpath -Wl,/usr/local/lib/../lib64
/usr/local/lib/../lib64/libstdc++.so: error adding symbols: File in wrong format
And when I rename /usr/local/lib64 to lib64_something, the program will compile without any errors. However, I want to find a permanent solution.
I've searched the internet for answers but none of them seem to really work. I've tried including -L/usr/local/lib to AM_LDFLAGS, AM_CFLAGS in configure.ac
I'd appreciate any input. Thank you.
Edit:Revised

Getting started with OpenCV on Macbook

I installed openCV on snow leopard with homebrew. Any opencv program I try to run cannot find the required header files.
I understand that the paths of the header files has to be defined. I need help with how I do that?
Use pkg-config to make your job easier:
g++ test.cpp -o test `pkg-config --cflags --libs opencv`

Libxml2: undefined reference to xmlTextReaderConstName

I have installed the latest libxml2-2.8.0, as usual: $ ./configure, $ make, $ make install.
The $ xml2-config --cflags --libs gives this output:
-I/usr/local/include/libxml2
-L/usr/local/lib -lxml2 -lm
But trying to compile any example...
$ gcc `xml2-config --cflags --libs` xmltest.c
The linker says:
/tmp/cc8ezrPl.o: In function `processNode':
xmltest.c:(.text+0x19): undefined reference to `xmlTextReaderConstName'
xmltest.c:(.text+0x38): undefined reference to `xmlTextReaderConstValue'
...etc.
Anything I've googled can be solved by xml2-config --cflags --libs flags, or upgrading to the latest version of libxml2, or something. Unfortunately, neither works for me.
What can be the steps to identify the problem?
Using Ubuntu 12.04 64-bit.
The libraries should be specified only after the source file so that the linker can resolve the undefined references in the source file. Try compiling the example with this
gcc -I/usr/local/include/libxml2 -L/usr/local/lib xmltest.c -lxml2 -lm

GTK3 program no longer compiles - GCC "undefined reference" at link time

So I was merrily learning GTK+ programming with 3.0 in Ubuntu 11.04, and even got a working ruler program running. It compiled with my makefile perfectly.
I took some time away from it, upgraded to 11.10, and now have come back to it. But, alas, when I try to build the program, I get a lot of "undefined reference" errors to pretty much every gtk call in my program. Compiling is fine - the issue is at link time.
The project can be found here: https://github.com/zjmichen/ruler
I've tested it and it compiled fine.
superman#superman-mint ~/work/zjmichen-ruler-e783fe1 $ make
gcc -c -Wall `pkg-config --cflags --libs gtk+-3.0` main.c
gcc -c -Wall `pkg-config --cflags --libs gtk+-3.0` window.c
gcc -c -Wall `pkg-config --cflags --libs gtk+-3.0` graphics.c
gcc -c -Wall `pkg-config --cflags --libs gtk+-3.0` mouse.c
gcc `pkg-config --cflags --libs gtk+-3.0` main.o window.o graphics.o mouse.o -o zruler
superman#superman-mint ~/work/zjmichen-ruler-e783fe1 $
But this was on Linux Mint. Here you've got the arguments produced by pkg-config
-pthread -DGSEAL_ENABLE -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gtk-3.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pixman-1 -pthread -L/usr/lib/x86_64-linux-gnu -lgtk-3 -lgdk-3 -latk-1.0 -lcairo-gobject -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
I've also did a quick test on Ubuntu 11.10 and indeed it doesn't compile. I'll take a better look this evening.
So I did test it on Ubuntu and changed the line 14 in the makefile to
$(CC) $(OBJS) $(GTKFLAGS) -o $(NAME)
this changes the order of object files and libraries that are being linked. I have no idea why this problem occurs on the new Ubuntu. Maybe it is because it is a different version of gcc. On my linux mint gcc is version 4.5.2 on ubuntu 11.10 it is 4.6.1
Unfortunately I currently don't have access to a running Linux machine with GTK3.0 installed, but looking at your code I noticed the inclusion of X11/xlib.h in main.c. Since you are not using X11 code anywhere in your code and you are using 'pkgconfig ... gtk+-3.0' instead of gtk+-X11-3.0, I assume you could remove that include statement. If you do need the X11 libraries the make sure it is listed in the compiler flags. I hope this helps :)

skipping incompatible library (lmono) while cross compiling c with mono

Ok for now i managed to call managed code (mono) from native C code
referring to:
http://www.mono-project.com/Embedding_Mono
which works on my host system (x86) ubuntu.
Now i try to crosscompile it for my target (arm) debian system.
Crosscompiler is arm-none-linux-gnueabi-gcc 2010 from Codesourcery
when i go for:
arm-none-linux-gnueabi-gcc 'pkg-config --cflags glib-2.0 --libs mono' -o main.o main.c
i get
Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lmono
so the libmono.so , libmono.a was found in /usr/lib and i go for:
arm-none-linux-gnueabi-gcc -L/usr/lib 'pkg-config --cflags glib-2.0 --libs mono' -o main.o main.c
which results in:
/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/libmono.so when searching for -lmono
/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/libmono.a when searching for -lmono
/Sourcery_G++_Lite/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lmono
somebody has advice?
best regards
Gobliins
Build libmono for ARM first, instead of trying to use your x86 build.

Resources