I'm really new to makefiles and also to the libraries or frameworks I'm using (Gtk, Gdk and OpenCL) to create a program which should display the mandelbrot set as a dynamic image.
I've created this make file based on a makefile provided by my professor. The problem I was having with his makefile is due to the fact that my professor was using another operating system, etc.
So, I've changed his makefile to this my new makefile:
GTK_PACKAGES=gdk-pixbuf-2.0 gtk+-2.0
GTK_CFLAGS=$(shell pkg-config --cflags $(GTK_PACKAGES))
GTK_LIBS=$(shell pkg-config --libs $(GTK_PACKAGES))
CFLAGS=-g -Wall -O2 -std=c99 $(GTK_CFLAGS)
LIBS=$(GTK_LIBS)
PROGS=opencl_mandelbrot
.PHONY: all
all: $(PROGS)
%: %.c
$(CC) $(CFLAGS) $(LDFLAGS) $*.c -framework OpenCL -o $@
%.o: %.c
$(CC) $(CFLAGS) -c $*.c -o $@
opencl_mandelbrot: opencl_mandelbrot.o opencl_util.o
$(CC) $(CFLAGS) $(LDFLAGS) opencl_mandelbrot.o opencl_util.o -framework OpenCL -o $@
.PHONY: clean
clean:
rm -f *.o $(PROGS)
But when I try to type make
on the terminal, I've the following error:
cc -g -Wall -O2 -std=c99 -D_REENTRANT -I/opt/X11/include/cairo -I/opt/X11/include/pixman-1 -I/opt/X11/include -I/opt/X11/include/freetype2 -I/opt/X11/include/libpng15 -I/opt/X11/include -I/usr/local/Cellar/gdk-pixbuf/2.32.3/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/gtk+/2.24.30/include/gtk-2.0 -I/usr/local/Cellar/gtk+/2.24.30/lib/gtk-2.0/include -I/usr/local/Cellar/pango/1.38.1/include/pango-1.0 -I/usr/local/Cellar/harfbuzz/1.2.6/include/harfbuzz -I/usr/local/Cellar/pango/1.38.1/include/pango-1.0 -I/usr/local/Cellar/atk/2.18.0_1/include/atk-1.0 -I/usr/local/Cellar/libpng/1.6.21/include/libpng16 -I/usr/local/Cellar/glib/2.46.2/include/glib-2.0 -I/usr/local/Cellar/glib/2.46.2/lib/glib-2.0/include -I/usr/local/opt/gettext/include -c opencl_mandelbrot.c -o opencl_mandelbrot.o
cc -g -Wall -O2 -std=c99 -D_REENTRANT -I/opt/X11/include/cairo -I/opt/X11/include/pixman-1 -I/opt/X11/include -I/opt/X11/include/freetype2 -I/opt/X11/include/libpng15 -I/opt/X11/include -I/usr/local/Cellar/gdk-pixbuf/2.32.3/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/gtk+/2.24.30/include/gtk-2.0 -I/usr/local/Cellar/gtk+/2.24.30/lib/gtk-2.0/include -I/usr/local/Cellar/pango/1.38.1/include/pango-1.0 -I/usr/local/Cellar/harfbuzz/1.2.6/include/harfbuzz -I/usr/local/Cellar/pango/1.38.1/include/pango-1.0 -I/usr/local/Cellar/atk/2.18.0_1/include/atk-1.0 -I/usr/local/Cellar/libpng/1.6.21/include/libpng16 -I/usr/local/Cellar/glib/2.46.2/include/glib-2.0 -I/usr/local/Cellar/glib/2.46.2/lib/glib-2.0/include -I/usr/local/opt/gettext/include opencl_mandelbrot.o opencl_util.o -framework OpenCL -o opencl_mandelbrot
Undefined symbols for architecture x86_64:
"_g_object_unref", referenced from:
_reallocate_pixbufs in opencl_mandelbrot.o
"_g_type_check_instance_cast", referenced from:
_main in opencl_mandelbrot.o
"_gdk_draw_pixbuf", referenced from:
_draw_mandelbrot_full_with_gpu in opencl_mandelbrot.o
"_gdk_pixbuf_get_height", referenced from:
_reallocate_pixbufs in opencl_mandelbrot.o
_recenter in opencl_mandelbrot.o
_draw_mandelbrot_full_with_gpu in opencl_mandelbrot.o
"_gdk_pixbuf_get_n_channels", referenced from:
_draw_mandelbrot_full_with_gpu in opencl_mandelbrot.o
"_gdk_pixbuf_get_pixels", referenced from:
_draw_mandelbrot_full_with_gpu in opencl_mandelbrot.o
"_gdk_pixbuf_get_rowstride", referenced from:
_reallocate_pixbufs in opencl_mandelbrot.o
_draw_mandelbrot_full_with_gpu in opencl_mandelbrot.o
"_gdk_pixbuf_get_width", referenced from:
_reallocate_pixbufs in opencl_mandelbrot.o
_recenter in opencl_mandelbrot.o
_draw_mandelbrot_full_with_gpu in opencl_mandelbrot.o
"_gdk_pixbuf_new", referenced from:
_reallocate_pixbufs in opencl_mandelbrot.o
"_gtk_init", referenced from:
_main in opencl_mandelbrot.o
"_gtk_main", referenced from:
_main in opencl_mandelbrot.o
"_gtk_main_quit", referenced from:
_destroy_window in opencl_mandelbrot.o
_keyboard_input in opencl_mandelbrot.o
"_gtk_object_get_type", referenced from:
_main in opencl_mandelbrot.o
"_gtk_signal_connect_full", referenced from:
_main in opencl_mandelbrot.o
"_gtk_widget_set_events", referenced from:
_main in opencl_mandelbrot.o
"_gtk_widget_show_all", referenced from:
_main in opencl_mandelbrot.o
"_gtk_window_get_type", referenced from:
_main in opencl_mandelbrot.o
"_gtk_window_new", referenced from:
_main in opencl_mandelbrot.o
"_gtk_window_resize", referenced from:
_main in opencl_mandelbrot.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [opencl_mandelbrot] Error 1
even though I've installed gtk
using brew
, but I guess the problem is related to the order of linkage or something similar...
I appreciate your help!