2016-05-17 14 views
1

私は本当にmakefileには新しく、ライブラリやフレームワーク(Gtk、Gdk、OpenCL)を使って、マンデルブロをダイナミックとして表示するプログラムを作成しています画像。アーキテクチャの定義されていないシンボルx86_64: "_g_object_unref"

私は教授が提供するmakefileに基づいてこのmakeファイルを作成しました。私は彼のメイクファイルを持っていた問題は、私の教授は、別のオペレーティングシステムを使用していたという事実のためである、など

だから、私はこの私の新しいメイクに彼のメイクファイルを変更しました:

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 [email protected] 

%.o: %.c 
    $(CC) $(CFLAGS) -c $*.c -o [email protected] 

opencl_mandelbrot: opencl_mandelbrot.o opencl_util.o 
    $(CC) $(CFLAGS) $(LDFLAGS) opencl_mandelbrot.o opencl_util.o -framework OpenCL -o [email protected] 

.PHONY: clean 
clean: 
    rm -f *.o $(PROGS) 

しかし、私はbrewを使用してgtkをインストールしたにも関わらず

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 

を、私は、問題が結合または類似した何かのために関連していると思います。私は、端末上でmakeを入力しようとすると、私は次のエラーをしました。 ..

私はあなたの助けに感謝します!

答えて

1
opencl_mandelbrot: opencl_mandelbrot.o opencl_util.o 
    $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) opencl_mandelbrot.o opencl_util.o -framework OpenCL -o [email protected] 

あなたはリンカエラーが出るように、それが指示されていなかったとして、リンカーは、シンボルを解決することはできませんので、あなたがLIBS変数にGTK +のリンカのフラグを割り当てるが、あなたのルールでは、あなたがLDFLAGS変数を使用するLIBS

1

を逃しました戦いの場所でそれらを探す。

変更:

LDFLAGS=$(GTK_LIBS) 

たり、リンカのルールに$(LIBS)を追加する

LIBS=$(GTK_LIBS) 

1

あなた自身のバグを追加してしまった組み込みルールを再作成しようとすると、コンパイルやリンクの方法を教えておく必要はありません。既に知っています。右の変数。

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) 
LDLIBS  := $(GTK_LIBS) 

PROGS := opencl_mandelbrot 

.PHONY: all clean 

all: $(PROGS) 

opencl_mandelbrot: LDFLAGS += -framework OpenCL 
opencl_mandelbrot: opencl_mandelbrot.o opencl_util.o 

clean: ; $(RM) *.o $(PROGS) 

ワイルドカードを使用してファイルを削除するときに注意してください。コードを再配布する場合は、悪い考えです。

関連する問題