We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Errors:
**** Build of configuration Default for project hello ****
make all arm-none-linux-gnueabi-gcc hello.o -o hello hello.o: In function 'main': /home/Gabriel/DS-5-Workspace/hello/hello.c:22: undefined reference to 'gtk_init' /home/Gabriel/DS-5-Workspace/hello/hello.c:23: undefined reference to 'gtk_window_new' /home/Gabriel/DS-5-Workspace/hello/hello.c:24: undefined reference to 'gtk_window_get_type' /home/Gabriel/DS-5-Workspace/hello/hello.c:24: undefined reference to 'g_type_check_instance_cast' /home/Gabriel/DS-5-Workspace/hello/hello.c:24: undefined reference to 'gtk_window_set_title' /home/Gabriel/DS-5-Workspace/hello/hello.c:25: undefined reference to 'gtk_widget_show' /home/Gabriel/DS-5-Workspace/hello/hello.c:26: undefined reference to 'gtk_main' collect2: ld returned 1 exit status make: *** [hello] Error 1
My makefile (original project Hello):
# C Application Example for ARM Linux # # Copyright (C) ARM Limited, 2007-2010. All rights reserved.
# This makefile is intended for use with GNU make # # This project can be built with either armcc or gcc by setting: # TOOLCHAIN = armcc # or # TOOLCHAIN = gcc
TOOLCHAIN = gcc
TARGET = hello CPU = -march=armv5te CC_OPTS = -c -O1 -g \ -I /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/include/gtk-2.0 \ -I /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/include/glib-2.0 \ -I /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/glib-2.0/include \ -I /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/include/cairo \ -I /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/include/pango-1.0 \ -I /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/gtk-2.0/include \ -I /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/include/atk-1.0 \ -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib \ -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/glib-2.0/include \ -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/gtk-2.0/include
OBJS = hello.o STRIPPED_DIR = stripped
##########################################################################
ifeq ($(strip $(TOOLCHAIN)),armcc) CONFIG_FILE = arm_linux_config.xml CPP = armcc --cpp --arm_linux_paths --arm_linux_config_file=$(CONFIG_FILE) --translate_g++ CC = armcc --arm_linux_paths --arm_linux_config_file=$(CONFIG_FILE) --translate_gcc AR = armar STRIP_APP = fromelf --strip debug,comment,symbols --elf STRIP_LIB = fromelf --strip debug,comment,symbols --elf else CONFIG_FILE = CPP = arm-none-linux-gnueabi-c++ CC = arm-none-linux-gnueabi-gcc AR = arm-none-linux-gnueabi-ar STRIP_APP = arm-none-linux-gnueabi-strip -R .comment --strip-all STRIP_LIB = arm-none-linux-gnueabi-strip -R .comment --strip-unneeded endif
# Select build rules based on Windows or Linux ifdef WINDIR WINPATH=$(subst /,\,$(1)) DONE=@if exist $(call WINPATH,$(1)) echo Build completed. define REAL_RM if exist $(call WINPATH,$(1)) del /q $(call WINPATH,$(1))
endef RM=$(foreach file,$(1),$(call REAL_RM,$(file))) SHELL=$(windir)\system32\cmd.exe MD=if not exist $(1) mkdir $(1) CP=copy else ifdef windir WINPATH=$(subst /,\,$(1)) DONE=@if exist $(call WINPATH,$(1)) echo Build completed. define REAL_RM if exist $(call WINPATH,$(1)) del /q $(call WINPATH,$(1))
endef RM=$(foreach file,$(1),$(call REAL_RM,$(file))) SHELL=$(windir)\system32\cmd.exe MD=if not exist $(1) mkdir $(1) CP=copy
else DONE=@if [ -f $(1) ]; then echo Build completed.; fi RM=rm -f $(1) MD=@if [ ! -d $(1) ]; then mkdir $(1); fi CP=cp endif endif
all: $(TARGET) $(call DONE,$(TARGET))
rebuild: clean all
clean: $(call RM,$(CONFIG_FILE)) $(call RM,$(OBJS)) $(call RM,$(TARGET)) $(call RM,$(STRIPPED_DIR)/$(TARGET))
# Create the configuration file so that the ARM compiler can find the GCC headers and libraries $(CONFIG_FILE): armcc --arm_linux_configure --arm_linux_config_file=$(CONFIG_FILE)
# Compile the sources $(OBJS): %.o: %.c $(CONFIG_FILE) $(CC) $(CPU) $(CC_OPTS) $< -o $@
# Link the objects together to create an executable # Strip the host/debug version to create a stripped/nodebug version for downloading to the target $(TARGET): $(OBJS) $(CONFIG_FILE) $(call MD,$(STRIPPED_DIR)) $(CC) $(OBJS) -o $(TARGET) $(STRIP_APP) $(TARGET) -o $(STRIPPED_DIR)/$(TARGET)
My small program:
#include <stdio.h> #include <gtk/gtk.h>
//int main(int argc, char** argv) //{ // printf("Hello world\n"); //} int main(int argc, char **argv) {
GtkWidget *janela; gtk_init(&argc, &argv); janela = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW (janela), "Alo Mundo"); gtk_widget_show(janela); gtk_main(); return 0;
}
Can anyone help?
"make all arm-none-linux-gnueabi-gcc hello.o -o hello hello.o: In function 'main': /home/Gabriel/DS-5-Workspace/hello/hello.c:22: undefined reference to 'gtk_init' /home/Gabriel/DS-5-Workspace/hello/hello.c:23: undefined reference to 'gtk_window_new' /home/Gabriel/DS-5-Workspace/hello/hello.c:24: undefined reference to 'gtk_window_get_type' /home/Gabriel/DS-5-Workspace/hello/hello.c:24: undefined reference to 'g_type_check_instance_cast' /home/Gabriel/DS-5-Workspace/hello/hello.c:24: undefined reference to 'gtk_window_set_title' /home/Gabriel/DS-5-Workspace/hello/hello.c:25: undefined reference to 'gtk_widget_show' /home/Gabriel/DS-5-Workspace/hello/hello.c:26: undefined reference to 'gtk_main' collect2: ld returned 1 exit status make: *** [hello] Error 1"
Those are linker errors. I don't see where you're linking in the GTK library.
Your Makefile is not using the -L options in the link step. Maybe you want to have
\t$(CC) $(OBJS) $(CC_OPTS) -o $(TARGET)
["\t" should be a TAB]
Or maybe split the -L options in CC_OPTS off into LD_OPTS and use that in the link step instead.
i am a beginner.. now i am facing the same problem but little different as
i want to create application in ARM board.. so i used the tool gtk for creating application..
my source file is base.c root@habesh-laptop:~# cd habesh/gtk/ root@habesh-laptop:~/habesh/gtk# ls base.c
i compiled it for ubuntu using root@habesh-laptop:~/habesh/gtk#gcc -o base base.c 'pkg-config --cflags --libs gtk+-2.0'
i can compile it for ubuntu and it works... this is where the toolchain is available... root@habesh-laptop:/opt/ARTOS_toolchain_1.3/bin# ls arm-linux-addr2line arm-linux-c++filt arm-linux-gcc-3.4.4 arm-linux-nm arm-linux-readelf ld pam_tally arm-linux-ar arm-linux-cpp arm-linux-gccbug arm-linux-objcopy arm-linux-size libpng12-config unix_chkpwd arm-linux-as arm-linux-g++ arm-linux-gcov arm-linux-objdump arm-linux-strings libpng-config arm-linux-c++ arm-linux-gcc arm-linux-ld arm-linux-ranlib arm-linux-strip mkimage
so i cross compiled for target using root@habesh-laptop:~/habesh/gtk# /opt/ARTOS_toolchain_1.3/bin/arm-linux-gcc -o trail base.c 'pkg-config --cflags --libs gtk+-2.0' /opt/ARTOS_toolchain_1.3/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld: cannot find -lgtk-x11-2.0 collect2: ld returned 1 exit status
what is the problem.. please help me...