我目前需要为 Windows 编译 GTK+ 应用程序。我的生成文件如下所示:
CC=g++
CFLAGS=-c -m32 -O0 -Wall -Wextra -Werror `pkg-config.exe --cflags --libs gtk+-2.0`
LDFLAGS=-m32 `pkg-config.exe --cflags --libs gtk+-2.0`
SOURCES=$(wildcard src/*.cpp)
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=screenplay
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@
pkg-config.exe 应该在哪里给我正确的 -I 和 -L 参数(例如包含文件和库文件所在的路径)。它实际上给了他们并不奇怪 - 输出是:
-mms-bitfields -IC:/MinGW/include/gtk-2.0 -IC:/MinGW/lib/gtk-2.0/include -IC:/MinGW/include/atk-1.0 -IC:/MinGW/include/cairo -IC:/MinGW/include/gdk-pixbuf-2.0 -IC:/MinGW/include/pango-1.0 -IC:/MinGW/include/glib-2.0 -IC:/MinGW/lib/glib-2.0/include -IC:/MinGW/include -IC:/MinGW/include/freetype2 -IC:/MinGW/include/libpng14 -LC:/MinGW/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl
我可以确认该位置 (C:/MinGW/lib/) 中存在库,但我收到未定义的参考错误。有任何想法吗?