我正在使用Linux mint和gcc-7以及mingw-w64。我想使用mingw在Linux中编译ac gtk3 +程序,以便它可以生成可以在windows中运行的.exe文件。我能够编译正常的c程序使用mingw,但我无法编译gtk程序。我可以用gcc编译gtk程序,但不能用mingw编译。
我按照这里的说法安装了mingw: - How to compile executable for Windows with GCC with Linux Subsystem?
现在我要编译我从https://developer.gnome.org/gtk3/stable/gtk-getting-started.html#id-1.2.3.5
获得的窗口程序 smit@smit-Aspire-5742:~/programs/c programs/test$ x86_64-w64-mingw32-gcc test.c `pkg-config --cflags gtk+-3.0 --libs`
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libgtk-3.dll.a when searching for -lgtk-3
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libgtk-3.dll.a when searching for -lgtk-3
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lgtk-3
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/li /libgdk-3.dll.a when searching for -lgdk-3
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libgdk-3.dll.a when searching for -lgdk-3
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk-3
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libpangocairo-1.0.dll.a when searching for -lpangocairo-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangocairo-1.0.lib when searching for -lpangocairo-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libpangocairo-1.0.dll.a when searching for -lpangocairo-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangocairo-1.0.lib when searching for -lpangocairo-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangocairo-1.0.lib when searching for -lpangocairo-1.0
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lpangocairo-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libpangoft2-1.0.dll.a when searching for -lpangoft2-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangoft2-1.0.lib when searching for -lpangoft2-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libpangoft2-1.0.dll.a when searching for -lpangoft2-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangoft2-1.0.lib when searching for -lpangoft2-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangoft2-1.0.lib when searching for -lpangoft2-1.0
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lpangoft2-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libfreetype.dll.a when searching for -lfreetype
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libfreetype.dll.a when searching for -lfreetype
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lfreetype
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libfontconfig.dll.a when searching for -lfontconfig
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/fontconfig.lib when searching for -lfontconfig
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libfontconfig.dll.a when searching for -lfontconfig
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/fontconfig.lib when searching for -lfontconfig
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/fontconfig.lib when searching for -lfontconfig
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lfontconfig
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libpangowin32-1.0.dll.a when searching for -lpangowin32-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangowin32-1.0.lib when searching for -lpangowin32-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libpangowin32-1.0.dll.a when searching for -lpangowin32-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangowin32-1.0.lib when searching for -lpangowin32-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pangowin32-1.0.lib when searching for -lpangowin32-1.0
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lpangowin32-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libpango-1.0.dll.a when searching for -lpango-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pango-1.0.lib when searching for -lpango-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libpango-1.0.dll.a when searching for -lpango-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pango-1.0.lib when searching for -lpango-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/pango-1.0.lib when searching for -lpango-1.0
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lpango-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libatk-1.0.dll.a when searching for -latk-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/atk-1.0.lib when searching for -latk-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libatk-1.0.dll.a when searching for -latk-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/atk-1.0.lib when searching for -latk-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/atk-1.0.lib when searching for -latk-1.0
/usr/bin/x86_64-w64-mingw32-ld: cannot find -latk-1.0
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libcairo-gobject.dll.a when searching for -lcairo-gobject
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libcairo-gobject.dll.a when searching for -lcairo-gobject
/usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo-gobject
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libcairo.dll.a when searching for -lcairo
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/cairo.lib when searching for -lcairo
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib/libcairo.dll.a when searching for -lcairo
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /opt/gtk3-dos/lib
所以.......(我粘贴最后一行,因为这个输出更大)
collect2: error: ld returned 1 exit status
我已经通过了这个教程: - http://www.tarnyko.net/en/?q=node/45
现在再次访问this tutorail,但这次我已经下载了gtk+-bundle_3.6.4-20131201_win64.zip
,现在我得到了这个输出: -
smit@smit-Aspire-5742:~/programs/c programs/test$ x86_64-w64-mingw32-gcc test.c `pkg-config --cflags gtk+-3.0 --libs`
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/gtk-3.0/gdk/gdkconfig.h:13,
from /usr/include/gtk-3.0/gdk/gdk.h:30,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from test.c:1:
/usr/include/glib-2.0/glib/gtypes.h: In function ‘_GLIB_CHECKED_ADD_U64’:
/usr/include/glib-2.0/glib/gmacros.h:232:53: error: size of array ‘_GStaticAssertCompileTimeAssertion_0’ is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:229:47: note: in definition of macro ‘G_PASTE_ARGS’
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^
/usr/include/glib-2.0/glib/gmacros.h:232:44: note: in expansion of macro ‘G_PASTE’
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gtypes.h:422:3: note: in expansion of macro ‘G_STATIC_ASSERT’
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
^
In file included from /usr/include/glib-2.0/gio/gio.h:46:0,
from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:28,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from test.c:1:
/usr/include/glib-2.0/gio/gcredentials.h: At top level:
/usr/include/glib-2.0/gio/gcredentials.h:75:1: error: unknown type name ‘uid_t’
uid_t g_credentials_get_unix_user (GCredentials *credentials,
^
/usr/include/glib-2.0/gio/gcredentials.h:79:52: error: unknown type name ‘uid_t’
uid_t uid,
^
答案 0 :(得分:0)
我已经通过this教程5或者更多次,我发现了什么问题。我正在从错误的目录中下载命令并下载错误版本的GTK+ 3 Windows binaries
。
我的mingw版本是mingw64因此我需要下载win64
版本。
我从/ opt / gtk3-win64执行命令export PKG_CONFIG_PATH=/opt/gtk3-win64/lib/pkgconfig
,但我需要通过test.c文件所在的目录执行此命令。
我将为未来的读者简化本教程。
按命令安装mingw cross-compiler
sudo apt-get install mingw-w64
然后从此处下载GTK+ 3 Windows binaries
(this教程中的链接已过时,此处为最新链接): - http://win32builder.gnome.org/
下载合适的版本,因为我下载了错误的版本。但是我犯了同样的错误。
通过命令
提取/opt/gtkwin
(推荐)中的zip文件
sudo mkdir /opt/gtkwin && sudo unzip <name of the zip file> -d /opt/gtkwin
然后转到已解压缩zip文件的目录。在这种情况下,我已在/ opt / gtkwin / like cd /opt/gtkwin
中解压缩并执行以下命令
find -name '*.pc' | while read pc; do sed -e "s@^prefix=.*@prefix=$PWD@" -i "$pc"; done
现在转到你有.c文件的目录,你要编译它。并执行这个命令
export PKG_CONFIG_PATH=/opt/gtkwin/lib/pkgconfig
现在按
编译程序x86_64-w64-mingw32-gcc test.c `pkg-config --cflags gtk+-3.0 --libs`
(对于64位)
和32位
i586-mingw32msvc-gcc test.c `pkg-config --cflags --libs gtk+-3.0`
此外,您应该访问本教程,因为我从那里了解到: - http://www.tarnyko.net/en/?q=node/45
这将创建.exe
文件,该文件无法在UNIX中运行,因为它的目标是在DOS上运行