I currently need to compile GTK+ application for Windows. My makefile looks like this:
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 $@
Where pkg-config.exe should give me correct -I and -L parameters (e.g. path where include files and library files are located). Not surprising it actually gives them - the output is:
-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
I can confirm that libs are present at the location (C:/MinGW/lib/), yet I receive undefined reference errors. Any ideas?
Makefile
yourself? Is CMake out of the picture? – thokramake
- compilation is successful, linking is the problem. Basically what I call: g++ -m32pkg-config.exe --cflags --libs gtk+-2.0
ALL_OBJECTS -o EXECUTABLE_NAMEz I receive undefined reference to gtk_main (and few others), like I wouldn't even link the libraries at linking step. – ZarakiKenpachi