gtk 在 windows 10 下工作吗
does gtk work under windows 10
我已经在 Windows 10/Surface Pro 2 上安装了 MinGW64 (MSYS2)。然后我用 pacman 安装了 GTK3 和许多其他软件包,所有 64 位版本。我什至能够 运行 gtk3-demo 并弹出 window。但是,我无法编译一个简单的 c 程序。
程序:
#include <gtk/gtk.h>
void on_window_destroy (GtkWidget *widget, gpointer user_data)
{
gtk_main_quit ();
/* quit main loop when windows closes */
}
int main (int argc, char *argv[])
{
GtkWidget *window, *label;
gtk_init (&argc,&argv);
/* initialize GTK+ */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* create the main window */
label = gtk_label_new ("Hello world !");
/* create a label with sample text */
gtk_container_add (GTK_CONTAINER (window), label);
/* define the label as window child*/
gtk_widget_show_all (window);
/* display window and children */
g_signal_connect (window, "destroy", G_CALLBACK(on_window_destroy), NULL);
/* connect the window closing event with the "on_window_destroy" function */
gtk_main ();
/* MAIN LOOP */
return 0;
}
它是用 pkg-config --cflags --libs gtk+-3.0
中的所有这些编译的,而且我还必须添加 -L /opt/x86_64-w64-mingw32/lib
才能让 pthread 工作。
编译:
gcc test.c -mms-bitfields -pthread -mms-bitfields -I/mingw64/include/gtk-3.0 -I/mingw64/include/cairo -I/mingw64/include -I/mingw64/include/pango-1.0 -I/mingw64/include/atk-1.0 -I/mingw64/include/cairo -I/mingw64/include/pixman-1 -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include/libpng16 -I/mingw64/include/harfbuzz -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include -I/mingw64/include/harfbuzz -I/mingw64/include/libpng16 -I/mingw64/include/gdk-pixbuf-2.0 -I/mingw64/include/libpng16 -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -L/mingw64/lib -LC:/building/msys64/mingw64/lib -L/mingw64/lib -LC:/building/msys64/mingw64/lib/../lib -L/mingw64/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lz -lepoxy -lpangocairo-1.0 -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lusp10 -lpango-1.0 -lm -latk-1.0 -lcairo-gobject -lcairo -lz -lpixman-1 -lfontconfig -lexpat -lfreetype -liconv -lexpat -lfreetype -lz -lbz2 -lharfbuzz -lpng16 -lz -lgdk_pixbuf-2.0 -lpng16 -lz -lgio-2.0 -lz -lgmodule-2.0 -pthread -lgobject-2.0 -lffi -lglib-2.0 -lintl -pthread -lws2_32 -lole32 -lwinmm -lshlwapi -lintl -L /opt/x86_64-w64-mingw32/lib
错误:
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll):(.text+0x0): multiple definition of `_fmode'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-xtxtmode.o):(.bss+0x0): first defined here
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x116): undefined reference to `__getmainargs'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x1dd): undefined reference to `__imp_GetStartupInfoA'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x22d): undefined reference to `__imp_Sleep'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x2ad): undefined reference to `_initterm'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x2da): undefined reference to `_initterm'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x349): undefined reference to `__imp_SetUnhandledExceptionFilter'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.__imp___initenv[.refptr.__imp___initenv]+0x0): undefined reference to `__imp___initenv'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.__imp__acmdln[.refptr.__imp__acmdln]+0x0): undefined reference to `__imp__acmdln'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-crt_handler.o): In function `__mingw_init_ehandler':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt_handler.c:87: undefined reference to `__imp_RtlAddFunctionTable'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-merr.o): In function `_matherr':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/merr.c:72: undefined reference to `fprintf'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-gs_support.o): In function `__security_init_cookie':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:62: undefined reference to `__imp_GetSystemTimeAsFileTime'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:70: undefined reference to `__imp_GetCurrentProcessId'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:74: undefined reference to `__imp_QueryPerformanceCounter'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-gs_support.o): In function `__report_gsfailure':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:111: undefined reference to `__imp_RtlCaptureContext'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:147: undefined reference to `__imp_SetUnhandledExceptionFilter'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:149: undefined reference to `__imp_GetCurrentProcess'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:150: undefined reference to `abort'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-pseudo-reloc.o): In function `__report_error':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/pseudo-reloc.c:156: undefined reference to `abort'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-atonexit.o): In function `mingw_onexit':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/atonexit.c:43: undefined reference to `_lock'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/atonexit.c:47: undefined reference to `__dllonexit'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/atonexit.c:51: undefined reference to `_unlock'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/atonexit.c:42: undefined reference to `__imp__onexit'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-pesect.o): In function `_FindPESectionByName':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/pesect.c:88: undefined reference to `strncmp'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-tlsthrd.o): In function `__mingw_TLScallback':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/tlsthrd.c:129: undefined reference to `__imp_InitializeCriticalSection'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-tlsthrd.o): In function `__mingwthr_run_key_dtors':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/tlsthrd.c:108: undefined reference to `__imp_TlsGetValue'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/tlsthrd.c:108: undefined reference to `__imp_TlsGetValue'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-tlsthrd.o): In function `__mingw_TLScallback':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/tlsthrd.c:145: undefined reference to `__imp_DeleteCriticalSection'
collect2.exe: error: ld returned 1 exit status
我该如何解决这个问题?
PS,我在安装MinGW64之前已经安装了GCC。或许新旧之间有些冲突?
MSYS2 没有安装任何东西到 "Program Files",所以在你的错误信息中看到 "c:/program files (x86)/gcc" 告诉我你的系统配置错误。我建议从您的 PATH 环境变量中删除先前安装的 GCC,这样您就不会在 MSYS2 中意外 运行 它。然后使用开始菜单中名为 "MinGW-w64 Win64 Shell" 的快捷方式启动 MSYS2 shell(或通过 运行ning mingw64_shell.bat)。然后 运行 这个命令来安装 64 位 MinGW 工具链包:
pacman -S mingw-w64-x86_64-toolchain
完成后,键入 which gcc
并验证它是 /mingw64/bin/gcc
。一旦您使用了正确的工具链,这可能会解决您的 GTK 问题。
此外,在我的 MSYS2 安装中 /opt
中没有任何内容。它只是一个空目录。如果您在 /opt
中有文件,那么我怀疑这是不正确的,您不应该尝试使用它们。要弄清楚 /opt
中有文件的原因,您可以 运行 pacman -Qo /path/to/some/file
查看 /opt
中的那些文件是否实际上属于某个包。
我已经在 Windows 10/Surface Pro 2 上安装了 MinGW64 (MSYS2)。然后我用 pacman 安装了 GTK3 和许多其他软件包,所有 64 位版本。我什至能够 运行 gtk3-demo 并弹出 window。但是,我无法编译一个简单的 c 程序。
程序:
#include <gtk/gtk.h>
void on_window_destroy (GtkWidget *widget, gpointer user_data)
{
gtk_main_quit ();
/* quit main loop when windows closes */
}
int main (int argc, char *argv[])
{
GtkWidget *window, *label;
gtk_init (&argc,&argv);
/* initialize GTK+ */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* create the main window */
label = gtk_label_new ("Hello world !");
/* create a label with sample text */
gtk_container_add (GTK_CONTAINER (window), label);
/* define the label as window child*/
gtk_widget_show_all (window);
/* display window and children */
g_signal_connect (window, "destroy", G_CALLBACK(on_window_destroy), NULL);
/* connect the window closing event with the "on_window_destroy" function */
gtk_main ();
/* MAIN LOOP */
return 0;
}
它是用 pkg-config --cflags --libs gtk+-3.0
中的所有这些编译的,而且我还必须添加 -L /opt/x86_64-w64-mingw32/lib
才能让 pthread 工作。
编译:
gcc test.c -mms-bitfields -pthread -mms-bitfields -I/mingw64/include/gtk-3.0 -I/mingw64/include/cairo -I/mingw64/include -I/mingw64/include/pango-1.0 -I/mingw64/include/atk-1.0 -I/mingw64/include/cairo -I/mingw64/include/pixman-1 -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include/libpng16 -I/mingw64/include/harfbuzz -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -I/mingw64/include -I/mingw64/include/freetype2 -I/mingw64/include -I/mingw64/include/harfbuzz -I/mingw64/include/libpng16 -I/mingw64/include/gdk-pixbuf-2.0 -I/mingw64/include/libpng16 -I/mingw64/include/glib-2.0 -I/mingw64/lib/glib-2.0/include -L/mingw64/lib -LC:/building/msys64/mingw64/lib -L/mingw64/lib -LC:/building/msys64/mingw64/lib/../lib -L/mingw64/lib -lgtk-3 -lgdk-3 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lz -lepoxy -lpangocairo-1.0 -lpangoft2-1.0 -lpangowin32-1.0 -lgdi32 -lusp10 -lpango-1.0 -lm -latk-1.0 -lcairo-gobject -lcairo -lz -lpixman-1 -lfontconfig -lexpat -lfreetype -liconv -lexpat -lfreetype -lz -lbz2 -lharfbuzz -lpng16 -lz -lgdk_pixbuf-2.0 -lpng16 -lz -lgio-2.0 -lz -lgmodule-2.0 -pthread -lgobject-2.0 -lffi -lglib-2.0 -lintl -pthread -lws2_32 -lole32 -lwinmm -lshlwapi -lintl -L /opt/x86_64-w64-mingw32/lib
错误:
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll):(.text+0x0): multiple definition of `_fmode'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-xtxtmode.o):(.bss+0x0): first defined here
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libkernel32.a(KERNEL32.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): string not null terminated in ILF object file.
c:/program files (x86)/gcc/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/opt/x86_64-w64-mingw32/lib/libmsvcrt.a(msvcrt.dll): Recognised but unhandled machine type (0x8664) in Import Library Format archive
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x116): undefined reference to `__getmainargs'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x1dd): undefined reference to `__imp_GetStartupInfoA'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x22d): undefined reference to `__imp_Sleep'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x2ad): undefined reference to `_initterm'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x2da): undefined reference to `_initterm'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.text+0x349): undefined reference to `__imp_SetUnhandledExceptionFilter'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.__imp___initenv[.refptr.__imp___initenv]+0x0): undefined reference to `__imp___initenv'
C:/Program Files (x86)/gcc/x86_64-w64-mingw32/lib/../lib/crt2.o:crtexe.c:(.rdata$.refptr.__imp__acmdln[.refptr.__imp__acmdln]+0x0): undefined reference to `__imp__acmdln'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-crt_handler.o): In function `__mingw_init_ehandler':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt_handler.c:87: undefined reference to `__imp_RtlAddFunctionTable'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-merr.o): In function `_matherr':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/merr.c:72: undefined reference to `fprintf'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-gs_support.o): In function `__security_init_cookie':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:62: undefined reference to `__imp_GetSystemTimeAsFileTime'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:70: undefined reference to `__imp_GetCurrentProcessId'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:74: undefined reference to `__imp_QueryPerformanceCounter'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-gs_support.o): In function `__report_gsfailure':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:111: undefined reference to `__imp_RtlCaptureContext'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:147: undefined reference to `__imp_SetUnhandledExceptionFilter'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:149: undefined reference to `__imp_GetCurrentProcess'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/gs_support.c:150: undefined reference to `abort'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-pseudo-reloc.o): In function `__report_error':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/pseudo-reloc.c:156: undefined reference to `abort'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-atonexit.o): In function `mingw_onexit':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/atonexit.c:43: undefined reference to `_lock'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/atonexit.c:47: undefined reference to `__dllonexit'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/atonexit.c:51: undefined reference to `_unlock'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/atonexit.c:42: undefined reference to `__imp__onexit'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-pesect.o): In function `_FindPESectionByName':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/pesect.c:88: undefined reference to `strncmp'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-tlsthrd.o): In function `__mingw_TLScallback':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/tlsthrd.c:129: undefined reference to `__imp_InitializeCriticalSection'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-tlsthrd.o): In function `__mingwthr_run_key_dtors':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/tlsthrd.c:108: undefined reference to `__imp_TlsGetValue'
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/tlsthrd.c:108: undefined reference to `__imp_TlsGetValue'
C:/msys64/opt/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-tlsthrd.o): In function `__mingw_TLScallback':
/msys_scripts/mingw-w64-cross-crt-git/src/mingw-w64/mingw-w64-crt/crt/tlsthrd.c:145: undefined reference to `__imp_DeleteCriticalSection'
collect2.exe: error: ld returned 1 exit status
我该如何解决这个问题?
PS,我在安装MinGW64之前已经安装了GCC。或许新旧之间有些冲突?
MSYS2 没有安装任何东西到 "Program Files",所以在你的错误信息中看到 "c:/program files (x86)/gcc" 告诉我你的系统配置错误。我建议从您的 PATH 环境变量中删除先前安装的 GCC,这样您就不会在 MSYS2 中意外 运行 它。然后使用开始菜单中名为 "MinGW-w64 Win64 Shell" 的快捷方式启动 MSYS2 shell(或通过 运行ning mingw64_shell.bat)。然后 运行 这个命令来安装 64 位 MinGW 工具链包:
pacman -S mingw-w64-x86_64-toolchain
完成后,键入 which gcc
并验证它是 /mingw64/bin/gcc
。一旦您使用了正确的工具链,这可能会解决您的 GTK 问题。
此外,在我的 MSYS2 安装中 /opt
中没有任何内容。它只是一个空目录。如果您在 /opt
中有文件,那么我怀疑这是不正确的,您不应该尝试使用它们。要弄清楚 /opt
中有文件的原因,您可以 运行 pacman -Qo /path/to/some/file
查看 /opt
中的那些文件是否实际上属于某个包。