Porting GTK3.0 project to GTK2.0

我与影子孤独终老i 提交于 2019-12-24 17:35:29

问题


I am building a simple GUI application which I have successfully deployed and run on my Raspberry PI dev board. However, due to issues with OpenCV being dependent on GTK+ v2.0, I have to back-port my application to an old version of GTK+. I'm already familiar with changing include paths, and so on, and library linking orders in my makefiles. However, when I make all the necessary changes, a fatal error occurs during build.

Building dependencies file for main.o
In file included from /opt/rpi/usr/include/gtk-2.0/gdk/gdkscreen.h:32:0,
             from /opt/rpi/usr/include/gtk-2.0/gdk/gdkapplaunchcontext.h:31,
             from /opt/rpi/usr/include/gtk-2.0/gdk/gdk.h:32,
             from /opt/rpi/usr/include/gtk-2.0/gtk/gtk.h:32,
             from inc/ui.h:8,
             from main.c:10:
/opt/rpi/usr/include/gtk-2.0/gdk/gdktypes.h:55:23: fatal error:
   gdkconfig.h: No such file or directory

I've confirmed that the missing file, gdkconfig.h exists for my GTK+ v3.0 installation:

find /opt/rpi/usr/include -iname "gdkconfig*"
./gtk-3.0/gdk/gdkconfig.h

But there is no such file for my GTK+ v2.0 installation. I've already installed the latest version via apt-get, but still no luck.

Are there any solutions to this issue?

Thank you.


回答1:


It turns out certain folders, including those with arm-linux-gnueabihf in the path, were not included by me manually, when they should have. In the end, I SSH'ed into the RPI device, and copied the output from the following command:

pkgconfig --clfags --libs gtk+-2.0

I then copied all the include directory statements (ie: those beginning with -I) and made a variable containing that massive string, and did something similar for all the library inclusions. The output from the above command is included below.

-pthread -I/usr/include/gtk-2.0 -I/usr/lib/arm-linux-gnueabihf/gtk-2.0/include
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0
-I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0
-I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/pixman-1
-I/usr/include/freetype2 -I/usr/include/libpng12  -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 -lglib-2.0

So, in short, this worked, and I didn't even have to change a single line of my code. Now everything works fine.



来源:https://stackoverflow.com/questions/22030177/porting-gtk3-0-project-to-gtk2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!