Windows 10的MSYS2中的链接-static GTK + -2.0程序(带有mingw64,不是mingw32)

时间:2018-09-24 17:48:01

标签: c windows gcc gtk2 msys2

我有一个可以在Linux上完美编译的程序,如果我不尝试使用-static标志将其链接,则可以在Windows上编译。 (我不得不说我没有在Linux中尝试-static,因为我认为它没有用。)

此外,尽管它在Windows中非静态链接且没有错误,但后来在运行程序时找不到.dll

使用:MSYS2(x64)中的mingw64(x64)与Windows 10(所有都是64位)。

当我尝试将其静态链接时,在最后阶段会出现以下错误:

 MINGW64 ~/mine-sweeper
$ make OS=win    
        CC      about_mod.o
        CC      ctrl_mod.o
        CC      game_mod.o
        CC      menu_mod.o
        CC      player_mod.o
        CC      save_mod.o
        CC      xyzzy_mod.o
        LD      modules.o

        CC      main.o

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgtk-win32-2.0
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgdk-win32-2.0
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile:30: mine-sweeper.exe] Error 1
make: *** [Makefile:205: binary] Error 2

主要Makefile:

################################################################################
# libs
LIBS_STATIC = -static

LIBS_MATH   = -l m
LIBS_CURSES = -l ncurses
LIBS_GTK    = `pkg-config --libs gtk+-2.0`

ifeq ($(OS), linux)
  LIBS      = $(LIBS_MATH) $(LIBS_CURSES) $(LIBS_GTK)
else ifeq ($(OS), win)
  LIBS      = $(LIBS_STATIC) $(LIBS_MATH) $(LIBS_CURSES) $(LIBS_GTK)
endif

export  LIBS

Makefile失败:

MAIN_OBJ_MODULES    = modules.o

MAIN_OBJS   = $(TMP_DIR)/main.o \
            $(patsubst %,$(MODULES_TMP_DIR)/%,$(MAIN_OBJ_MODULES))


$(BIN_NAME): $(MAIN_OBJS)
    $(Q)$(CC) $^ -o $@ $(LIBS)
    @echo  "    CC  $@"
    @echo  ""

为什么要寻找32位的东西?

缺少什么?

编辑:

pkg-config --libs gtk+-2.0的输出是:

 MINGW64 ~/mine-sweeper
$ pkg-config --libs gtk+-2.0
-LC:/msys64/mingw64/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lpangowin32-1.0 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl

编辑:

GTK + -2.0的安装软件包为:

mingw64/mingw-w64-x86_64-gtk2 2.24.32-2 [installed]
    GTK+ is a multi-platform toolkit (v2) (mingw-w64)

编辑:

所请求的库似乎存在:

MINGW64 ~
$ find / |grep gtk-win32-2.0
/home/i5-5675C/mine-sweeper/bin/libgtk-win32-2.0-0.dll
/mingw64/bin/libgtk-win32-2.0-0.dll
/mingw64/lib/libgtk-win32-2.0.dll.a
find: failed to read file names from file system at or below ‘/’: No such file or directory

MINGW64 ~
$ find / |grep gdk-win32-2.0
/home/i5-5675C/mine-sweeper/bin/libgdk-win32-2.0-0.dll
/mingw64/bin/libgdk-win32-2.0-0.dll
/mingw64/lib/libgdk-win32-2.0.dll.a
/mingw64/lib/pkgconfig/gdk-win32-2.0.pc
find: failed to read file names from file system at or below ‘/’: No such file or directory

MINGW64 ~
$

0 个答案:

没有答案