无法在Fedora Eclipse上构建GTK+ Windows应用程序

Can not build GTK+ Windows application on Fedora Eclipse

本文关键字:构建 GTK+ Windows 应用程序 Eclipse Fedora      更新时间:2023-10-16

我尝试用MinGW在Fedora x64 Eclipse上为Windows x86构建一个非常简单的应用程序。应用程序编译好了,但是,它不能链接。我的链接命令如下:

i686-w64-mingw32-g++ `mingw32-pkg-config --libs gtk+-2.0` -o "GtkTest"  ./main.o

当我运行mingw32-pkg-config——libs gtk+-2.0时,输出如下:

-Wl,-luuid -L/usr/i686-w64-mingw32/sys-root/mingw/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -limm32 -lshell32 -lole32 -latk-1.0 -lpangocairo-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lfreetype -lfontconfig -lpango-1.0 -lm -lcairo -lgobject-2.0 -lglib-2.0 -lintl

毫无疑问文件夹和库文件是存在的。但是,我收到以下错误:

./main.o:main.cpp:(.text.startup+0x3e): undefined reference to `gtk_init_abi_check'
./main.o:main.cpp:(.text.startup+0x43): undefined reference to `gtk_builder_new'
./main.o:main.cpp:(.text.startup+0x3d): undefined reference to `gtk_builder_add_from_file'
./main.o:main.cpp:(.text.startup+0x46): undefined reference to `gtk_widget_get_type'
./main.o:main.cpp:(.text.startup+0x58): undefined reference to `gtk_builder_get_object'
./main.o:main.cpp:(.text.startup+0x64): undefined reference to `g_type_check_instance_cast'
./main.o:main.cpp:(.text.startup+0x76): undefined reference to `gtk_builder_connect_signals'
./main.o:main.cpp:(.text.startup+0x86): undefined reference to `g_type_check_instance_cast'
./main.o:main.cpp:(.text.startup+0x8e): undefined reference to `g_object_unref'
./main.o:main.cpp:(.text.startup+0x96): undefined reference to `gtk_widget_show'
./main.o:main.cpp:(.text.startup+0x9b): undefined reference to `gtk_main'
./main.o:main.cpp:(.text.startup+0xcb): undefined reference to `g_log'
./main.o:main.cpp:(.text.startup+0xd7): undefined reference to `g_free'

所以,看起来链接器根本看不到库,即使它们存在并且我在命令行中引用它们。原因是什么?

您缺少--cflags,但最重要的是,顺序错误。查看Tor Lillqvist关于正确标记排序的建议