0
votes

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?

1
Is there a good reason you write a Makefile yourself? Is CMake out of the picture?thokra
Pasting the resulting compilation command lines and the actual errors you are getting is likely going to be helpful in getting your problem solved.Etan Reisner
Classical call of make - compilation is successful, linking is the problem. Basically what I call: g++ -m32 pkg-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

1 Answers

0
votes

Have you checked where the gtk libraries are actually installed? You seem to only have -LC:/MinGW/lib for you library path are you sure all the libraries are in there? By the way I think you only need to pass --cflags to pkg-config to set CFLAGS and --libs to set LDFLAGS you don't need both.