I have a program which compiles perfectly in Linux, and compiles in Windows if I don't try to link it with -static
flag. (I have to say I didn't try -static
in linux, as I don't find it useful).
Also, although it links non-statically in windows without errors, it later fails finding the .dll
s when I run the program.
Using: MSYS2
(x64) with mingw64
in Windows 10
(x64) (everything is 64bit).
When I try to link it statically, it gives the following error in the last stage:
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
Main 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
Failing 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 ""
Why is it looking for something called 32?
What is missing?
EDIT:
Output of pkg-config --libs gtk+-2.0
is:
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
EDIT:
The installed package of GTK+-2.0 is:
mingw64/mingw-w64-x86_64-gtk2 2.24.32-2 [installed]
GTK+ is a multi-platform toolkit (v2) (mingw-w64)
EDIT:
The requested libs seem to exist:
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 ~
$