This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems with Libs GTK

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?

Parents
  • "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.

Reply
  • "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.

Children
  • I think this is enough here (I'm beginner...):

    -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

  • "I think this is enough here "

    OK, if you say so.

  • "???"

    Well, I was thinking that you'd want to specify what library to link to, not just where to look for unnamed libraries.

    You wrote that you thought the where was enough, so I have nothing more to add.

  • I think there was a misunderstanding, I put the following lines in the makefile:

    C_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/libgtk-x11-2.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libgdk-x11-2.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libgio-2.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libglib-2.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libatk-1.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libcairo.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libexpat.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libfontconfig.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libfreetype.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libgdk_pixbuf-2.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libgmodule-2.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libgobject-2.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libpangocairo-1.0.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libpangoft2.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libpixman-1.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libpng12.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libx11.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libXau.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libXcursor.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libXdmcp.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libXext.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libXfixes.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libXrandr.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libXrender.so \
    -L /home/Gabriel/DS-5-Workspace/distribution/filesystem/armv5t_mtx/usr/lib/libz.so \
    -L /home/Gabriel/DS-5-Workspace/gnometris/libgames-support.so \
    -L /home/Gabriel/DS-5-Workspace/example_library/libsorts.so
    OBJS = hello.o
    STRIPPED_DIR = stripped

    It continues:

    **** 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 doubt is whether the procedure was correct, if so, does anyone know what the libs that I put in patches? If not, what the correct procedure?

  • "My doubt is whether the procedure was correct ..."

    I also was doubting whether your procedure is correct because I could only see your "-L" specifications for where the linker should look for libraries and could not find the "-l" specification for which libraries to link.

    sourceware.org/.../Options.html