Thread: Undefined reference when building gtk applications

  1. #1
    Registered User
    Join Date
    Sep 2019
    Posts
    15

    Undefined reference when building gtk applications

    Hello. I have been trying to build gimp from source. Yer, every time I execute configure, it fails with a message

    Code:
    *** Could not run GTK+ test program, checking why...
    *** The test program failed to compile or link. See the file config.log for the
    *** exact error that occured. This usually means GTK+ is incorrectly installed.
    configure: error: Test for GTK+ failed. See the file 'INSTALL' for help
    Looking into config.log, there is:
    Code:
    configure:28333: gcc -o conftest -g -O2 -Wall -Wdeclaration-after-statement -Wmissing-prototypes -Wmissing-declarations -Winit-self -Wpointer-arith -Wold-style-definition  -I/media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/include -I/media/34GB/Arquivos-de-Programas-Linux/xorg/Xorgproto-2018.1/include/ -I/media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/include/gtk-2.0/ -I/media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/include/glib-2.0/ -I/media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/lib/glib-2.0/include/ -I/media/34GB/Arquivos-de-Programas-Linux/Cairo-1.10.0/include/cairo/ -I/media/34GB/Arquivos-de-Programas-Linux/Pango-1.30.0/include/pango-1.0/ -I/media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/gtk-2.0/include/ -I/media/34GB/Arquivos-de-Programas-Linux/Gdk-pixbuf-2.25.2/include/gdk-pixbuf-2.0/ -I/media/34GB/Arquivos-de-Programas-Linux/Atk-2.15.4/include/atk-1.0/ -L/media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/lib/ conftest.c   >&5
    conftest.c: In function 'main':
    conftest.c:50:1: warning: old-style function definition [-Wold-style-definition]
     main ()
     ^
    /usr/bin/ld: Dwarf Error: found dwarf version '4', this reader only handles version 2 and 3 information.
    /tmp/ccB33dRl.o: In function `main':
    conftest.c:(.text.startup+0x2): undefined reference to `gtk_major_version'
    /usr/bin/ld: Dwarf Error: found dwarf version '0', this reader only handles version 2 and 3 information.
    conftest.c:(.text.startup+0x11): undefined reference to `gtk_minor_version'
    /usr/bin/ld: Dwarf Error: found dwarf version '315', this reader only handles version 2 and 3 information.
    conftest.c:(.text.startup+0x1c): undefined reference to `gtk_micro_version'
    collect2: error: ld returned 1 exit status
    configure:28339: $? = 1
    configure: failed program was:
    | /* confdefs.h.  */
    | #define PACKAGE_NAME "GIMP"
    | #define PACKAGE_TARNAME "gimp"
    | #define PACKAGE_VERSION "2.6.0"
    | #define PACKAGE_STRING "GIMP 2.6.0"
    | #define PACKAGE_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=GIMP"
    | #define GETTEXT_PACKAGE "gimp20"
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_TYPES_H 1
    | #define HAVE_SYS_STAT_H 1
    | #define HAVE_STDLIB_H 1
    | #define HAVE_STRING_H 1
    | #define HAVE_MEMORY_H 1
    | #define HAVE_STRINGS_H 1
    | #define HAVE_INTTYPES_H 1
    | #define HAVE_STDINT_H 1
    | #define HAVE_UNISTD_H 1
    | #define HAVE_DLFCN_H 1
    | #define ARCH_X86 1
    | #define ARCH_X86_64 1
    | #define STDC_HEADERS 1
    | #define HAVE_SYS_WAIT_H 1
    | #define TIME_WITH_SYS_TIME 1
    | #define HAVE_SYS_PARAM_H 1
    | #define HAVE_SYS_TIME_H 1
    | #define HAVE_SYS_TIMES_H 1
    | #define HAVE_SYS_WAIT_H 1
    | #define HAVE_UNISTD_H 1
    | #define RETSIGTYPE void
    | #define HAVE_VPRINTF 1
    | #define HAVE_ALLOCA_H 1
    | #define HAVE_ALLOCA 1
    | #define HAVE_DIFFTIME 1
    | #define HAVE_MMAP 1
    | #define HAVE__NL_MEASUREMENT_MEASUREMENT 1
    | #define HAVE_LOCALE_H 1
    | #define HAVE_LC_MESSAGES 1
    | #define HAVE_BIND_TEXTDOMAIN_CODESET 1
    | #define HAVE_GETTEXT 1
    | #define HAVE_DCGETTEXT 1
    | #define ENABLE_NLS 1
    | #define HAVE_ISO_CODES 1
    | #define HAVE_BIND_TEXTDOMAIN_CODESET 1
    | /* end confdefs.h.  */
    | 
    | #include <gtk/gtk.h>
    | #include <stdio.h>
    | 
    | int
    | main ()
    | {
    |  return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version));
    |   ;
    |   return 0;
    | }
    configure:28370: error: Test for GTK+ failed. See the file 'INSTALL' for help.
    Then I tried to build this test by my own:

    Code:
    #include <gtk/gtk.h>
     #include <stdio.h>
     
     int
     main ()
     {
      return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version));
       ;
       return 0;
     }
    with
    Code:
    gcc -o conftest2 -I /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/include/gtk-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Cairo-1.10.0/include/cairo/ -I /media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/include/glib-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/lib/glib-2.0/include/ -I /media/34GB/Arquivos-de-Programas-Linux/Pango-1.30.0/include/pango-1.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/gtk-2.0/include/ -I /media/34GB/Arquivos-de-Programas-Linux/Atk-2.15.4/include/atk-1.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Gdk-pixbuf-2.25.2/include/gdk-pixbuf-2.0/ conftest2.c
    and received:
    Code:
    /tmp/ccCdzV54.o: In function `main':
    conftest2.c:(.text+0x6): undefined reference to `gtk_major_version'
    conftest2.c:(.text+0x10): undefined reference to `gtk_minor_version'
    conftest2.c:(.text+0x1a): undefined reference to `gtk_micro_version'
    collect2: error: ld returned 1 exit status
    I tried to check if the system gtk had these
    gtk_whatever_version
    on it and executed:

    Code:
    nm -s /usr/lib/libgtk-x11-2.0.so.0.2000.0 | grep gtk_major_version
    that returned:
    nm: /usr/lib/libgtk-x11-2.0.so.0.2000.0: no symbols
    I then tested with my two own built libgtk:

    Code:
     nm -s /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/libgtk-x11-2.0.so.0.2400.20 | grep gtk_major_version
    that returned
    Code:
    0000000000344f64 R gtk_major_version
    and
    Code:
    nm -s /media/34GB/Arquivos-de-Programas-Linux-32bit/Gtk+-2.12.0/lib/libgtk-x11-2.0.so.0.1200.0 | grep gtk_major_version
    that returned:

    Code:
    003821c0 R gtk_major_version
    Then I did my last attempts, tried to build the conftest example using my own gtks (-L added).

    Code:
    gcc -o conftest2 -I /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/include/gtk-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Cairo-1.10.0/include/cairo/ -I /media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/include/glib-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/lib/glib-2.0/include/ -I /media/34GB/Arquivos-de-Programas-Linux/Pango-1.30.0/include/pango-1.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/gtk-2.0/include/ -I /media/34GB/Arquivos-de-Programas-Linux/Atk-2.15.4/include/atk-1.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Gdk-pixbuf-2.25.2/include/gdk-pixbuf-2.0/ -L /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/ conftest2.c
    and

    Code:
    gcc -m32 -o conftest2 -I /media/34GB/Arquivos-de-Programas-Linux-32bit/Gtk+-2.12.0/include/gtk-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux-32bit/Cairo-1.2.6/include/cairo/ -I /media/34GB/Arquivos-de-Programas-Linux-32bit/Glib-2.20.0/include/glib-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux-32bit/Glib-2.20.0/lib/glib-2.0/include/ -I /media/34GB/Arquivos-de-Programas-Linux-32bit/Pango-1.20.5/include/pango-1.0/ -I /media/34GB/Arquivos-de-Programas-Linux-32bit/Gtk+-2.12.0/lib/gtk-2.0/include/ -I /media/34GB/Arquivos-de-Programas-Linux-32bit/Atk-1.29.2/include/atk-1.0/ -L /media/34GB/Arquivos-de-Programas-Linux-32bit/Gtk+-2.12.0/lib/  conftest2.c
    Both returned:

    Code:
    conftest2.c:(.text+0x4): undefined reference to `gtk_major_version'
    conftest2.c:(.text+0xd): undefined reference to `gtk_minor_version'
    conftest2.c:(.text+0x16): undefined reference to `gtk_micro_version'
    So, any suggestions as to why this is happening?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    All your command lines are missing one or more -l options

    -L (uppercase) tells the linker where to look for libraries
    -l (lowercase) tells the linker the names of libraries to examine.

    If your actual library name is libfoo.a or libfoo.so, you say -lfoo on the command line.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Random guess you are missing the GTL devel packages that contains the GTK headers.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  4. #4
    Registered User
    Join Date
    Mar 2023
    Posts
    1
    What causes the "undefined reference" error when building GTK applications, and how can it be resolved?

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > What causes the "undefined reference" error when building GTK applications,
    Undefined reference errors typically have the following causes (all are general, and not GTK specific).
    - You forgot to implement a function / declare a variable.
    - You mis-spelled the symbol in question, either trying to define it, or trying to use it. So for example, myprint != myPrint != my_print.
    - You forgot to name the library (or libraries) where 3rd party symbols are declared (those are the -l options)
    - You forgot to name the library locations (those are the -L options).

    > and how can it be resolved?
    Fix the problem(s) mentioned above.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Sep 2019
    Posts
    15
    Based on the above comment I tried to add:
    Code:
    -L/media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/ -lgtk-x11-2.0"
    to the LDFLAGS. Yet now I am receiving:
    Code:
    configure:28134: checking for GTK+ - version >= 2.12.1
    configure:28295: result: no
    configure:28333: gcc -o conftest -g -O2 -Wall -Wdeclaration-after-statement -Wmissing-prototypes -Wmissing-declarations -Winit-self -Wpointer-arith -Wold-style-definition  -I /media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/include/ -I /media/34GB/Arquivos-de-Programas-Linux/xorg/Xorgproto-2018.1/include/ -I /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/include/gtk-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/gtk-2.0/include/ -I /media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/include/glib-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/lib/glib-2.0/include/ -I /media/34GB/Arquivos-de-Programas-Linux/Cairo-1.10.0/include/cairo/ -I /media/34GB/Arquivos-de-Programas-Linux/Pango-1.30.0/include/pango-1.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Gdk-pixbuf-2.25.2/include/gdk-pixbuf-2.0/ -I /media/34GB/Arquivos-de-Programas-Linux/Atk-2.20.0/include/atk-1.0/ -L/media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/lib/ -L/media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/ -lgtk-x11-2.0 conftest.c   >&5
    conftest.c: In function 'main':
    conftest.c:49:1: warning: old-style function definition [-Wold-style-definition]
     main ()
     ^
    configure:28339: $? = 0
    configure:28370: error: Test for GTK+ failed. See the file 'INSTALL' for help.
    On the command line there is:
    Code:
    checking for GTK+ - version >= 2.12.1... PKG_CONFIG: /usr/bin/pkg-config
    min_gtk_version: 2.12.1
    pkg_config_args: gtk+-2.0 gthread-2.0
    no_gtk variable: yes
    no
    *** Could not run GTK+ test program, checking why...
    *** The test program compiled, but did not run. This usually means
    *** that the run-time linker is not finding GTK+ or finding the wrong
    *** version of GTK+. If it is not finding GTK+, you'll need to set your
    *** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point
    *** to the installed location  Also, make sure you have run ldconfig if that
    *** is required on your system
    ***
    *** If you have an old version installed, it is best to remove it, although
    *** you may also be able to get things to work by modifying LD_LIBRARY_PATH
    configure: error: Test for GTK+ failed. See the file 'INSTALL' for help.
    I was thinking into opening configure.in, or even configure when I had an idea: It might be the order of the parameters? On my separate conftest.c I am able to compile it, but the -L and the -l come after the conftest.c when calling gcc. Here they are before it. This might be the cause?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    What does the output of ldd tell you?
    Code:
    $ ldd conftest
    	linux-vdso.so.1 (0x00007ffe4a7fb000)
    	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f694a600000)
    	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f694a519000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f694a200000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f694a8ea000)
    	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f694a8a8000)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Sep 2019
    Posts
    15
    Quote Originally Posted by Salem View Post
    What does the output of ldd tell you?
    Code:
    $ ldd conftest
        linux-vdso.so.1 (0x00007ffe4a7fb000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f694a600000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f694a519000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f694a200000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f694a8ea000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f694a8a8000)
    Do you mean my own conftest (as configure remove its conftest?). It shows a million libraries, among them
    Code:
    /usr/lib/libgtk-x11-2.0.so.0
    Currently checking the gtk detection code to see if I figure out the cause. I will copy and paste it here too:

    Code:
    if test "${enable_gtktest+set}" = set; then :
      enableval=$enable_gtktest;
    else
      enable_gtktest=yes
    fi
    
    
      pkg_config_args=gtk+-2.0
      for module in . gthread
      do
          case "$module" in
             gthread)
                 pkg_config_args="$pkg_config_args gthread-2.0"
             ;;
          esac
      done
    
      no_gtk=""
    
      # Extract the first word of "pkg-config", so it can be a program name with args.
    set dummy pkg-config; ac_word=$2
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
    $as_echo_n "checking for $ac_word... " >&6; }
    if ${ac_cv_path_PKG_CONFIG+:} false; then :
      $as_echo_n "(cached) " >&6
    else
      case $PKG_CONFIG in
      [\\/]* | ?:[\\/]*)
      ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
      ;;
      *)
      as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    for as_dir in $PATH
    do
      IFS=$as_save_IFS
      test -z "$as_dir" && as_dir=.
        for ac_exec_ext in '' $ac_executable_extensions; do
      if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
        ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
        $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
        break 2
      fi
    done
      done
    IFS=$as_save_IFS
    
      test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
      ;;
    esac
    fi
    PKG_CONFIG=$ac_cv_path_PKG_CONFIG
    
    if test -n "$PKG_CONFIG"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
    $as_echo "$PKG_CONFIG" >&6; }
    else
      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
    $as_echo "no" >&6; }
    fi
    
    
    
      if test x$PKG_CONFIG != xno ; then
        if pkg-config --atleast-pkgconfig-version 0.7 ; then
          :
        else
          echo "*** pkg-config too old; version 0.7 or better required."
          no_gtk=yes
          PKG_CONFIG=no
        fi
      else
        no_gtk=yes
      fi
    
      min_gtk_version=2.12.5
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GTK+ - version >= $min_gtk_version" >&5
    $as_echo_n "checking for GTK+ - version >= $min_gtk_version... " >&6; }
    
      if test x$PKG_CONFIG != xno ; then
        ## don't try to run the test against uninstalled libtool libs
        if $PKG_CONFIG --uninstalled $pkg_config_args; then
          echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
          enable_gtktest=no
        fi
    
        if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
    echo "BOTO!"
          :
        else
          no_gtk=yes
        fi
      fi
    
      if test x"$no_gtk" = x ; then
        GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
        GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
        gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
               sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'`
        gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
               sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'`
        gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
               sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'`
        if test "x$enable_gtktest" = "xyes" ; then
          ac_save_CFLAGS="$CFLAGS"
          ac_save_LIBS="$LIBS"
          CFLAGS="$CFLAGS $GTK_CFLAGS"
          LIBS="$GTK_LIBS $LIBS"
          rm -f conf.gtktest
          if test "$cross_compiling" = yes; then :
      echo $ac_n "cross compiling; assumed OK... $ac_c"
    else
      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    /* end confdefs.h.  */
    
    #include <gtk/gtk.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    int
    main ()
    {
      int major, minor, micro;
      char *tmp_version;
    
      fclose (fopen ("conf.gtktest", "w"));
    
      /* HP/UX 9 (%@#!) writes to sscanf strings */
      tmp_version = g_strdup("$min_gtk_version");
      if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
         printf("%s, bad version string\n", "$min_gtk_version");
         exit(1);
       }
    
      if ((gtk_major_version != $gtk_config_major_version) ||
          (gtk_minor_version != $gtk_config_minor_version) ||
          (gtk_micro_version != $gtk_config_micro_version))
        {
          printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
                 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
                 gtk_major_version, gtk_minor_version, gtk_micro_version);
          printf ("*** was found! If pkg-config was correct, then it is best\n");
          printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
          printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
          printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
          printf("*** required on your system.\n");
          printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
          printf("*** to point to the correct configuration files\n");
        }
      else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
           (gtk_minor_version != GTK_MINOR_VERSION) ||
               (gtk_micro_version != GTK_MICRO_VERSION))
        {
          printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
             GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
          printf("*** library (version %d.%d.%d)\n",
             gtk_major_version, gtk_minor_version, gtk_micro_version);
        }
      else
        {
          if ((gtk_major_version > major) ||
            ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
            ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
          {
            return 0;
           }
         else
          {
            printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
                   gtk_major_version, gtk_minor_version, gtk_micro_version);
            printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
               major, minor, micro);
            printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
            printf("***\n");
            printf("*** If you have already installed a sufficiently new version, this error\n");
            printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
            printf("*** being found. The easiest way to fix this is to remove the old version\n");
            printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
            printf("*** correct copy of pkg-config. (In this case, you will have to\n");
            printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
            printf("*** so that the correct libraries are found at run-time))\n");
          }
        }
      return 1;
    }
    
    _ACEOF
    if ac_fn_c_try_run "$LINENO"; then :
    
    else
      no_gtk=yes
    fi
    rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
      conftest.$ac_objext conftest.beam conftest.$ac_ext
    fi
    
           CFLAGS="$ac_save_CFLAGS"
           LIBS="$ac_save_LIBS"
         fi
      fi
      if test "x$no_gtk" = x ; then
          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (version  $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version)"  >&5
    $as_echo "yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version)" >&6; }
         :
      else
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
    $as_echo "no" >&6; }
         if test "$PKG_CONFIG" = "no" ; then
           echo "*** A new enough version of pkg-config was not found."
           echo "*** See http://pkgconfig.sourceforge.net"
         else
           if test -f conf.gtktest ; then
            :
           else
              echo "*** Could not run GTK+ test program, checking why..."
          ac_save_CFLAGS="$CFLAGS"
          ac_save_LIBS="$LIBS"
              CFLAGS="$CFLAGS $GTK_CFLAGS"
              LIBS="$LIBS $GTK_LIBS"
              cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    /* end confdefs.h.  */
    
    #include <gtk/gtk.h>
    #include <stdio.h>
    
    int
    main ()
    {
     return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version));
      ;
      return 0;
    }
    _ACEOF
    if ac_fn_c_try_link "$LINENO"; then :
       echo "*** The test program compiled, but did not run. This usually means"
              echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
              echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
              echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
              echo "*** to the installed location  Also, make sure you have run ldconfig if that"
              echo "*** is required on your system"
          echo "***"
              echo "*** If you have an old version installed, it is best to remove it, although"
              echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
    else
       echo "*** The test program failed to compile or link. See the file config.log for the"
              echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."
    fi
    rm -f core conftest.err conftest.$ac_objext \
        conftest$ac_exeext conftest.$ac_ext
              CFLAGS="$ac_save_CFLAGS"
              LIBS="$ac_save_LIBS"
           fi
         fi
         GTK_CFLAGS=""
         GTK_LIBS=""
         as_fn_error $? "Test for GTK+ failed. See the file 'INSTALL' for help." "$LINENO" 5
      fi
    
    
      rm -f conf.gtktest
    
    
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if GTK+ is version 2.15.0 or newer" >&5
    $as_echo_n "checking if GTK+ is version 2.15.0 or newer... " >&6; }
    if $PKG_CONFIG --atleast-version=2.15.0 gtk+-2.0; then
      have_gtk_2_15=yes
    else
      have_gtk_2_15=no
    fi
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gtk_2_15" >&5
    $as_echo "$have_gtk_2_15" >&6; }

    and also my configure command

    Code:
    LD_LIBRARY_PATH=/media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/lib/   CPPFLAGS="-I/media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/include/   -I/media/34GB/Arquivos-de-Programas-Linux/xorg/Xorgproto-2018.1/include/  -I/media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/include/gtk-2.0/  -I/media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/include/glib-2.0/   -I/media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/lib/glib-2.0/include  -I/media/34GB/Arquivos-de-Programas-Linux/Cairo-1.10.0/include/cairo/  -I/media/34GB/Arquivos-de-Programas-Linux/Pango-1.30.0/include/pango-1.0/   -I/media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/gtk-2.0/include/   -I/media/34GB/Arquivos-de-Programas-Linux/Gdk-pixbuf-2.25.2/include/gdk-pixbuf-2.0/  -I/media/34GB/Arquivos-de-Programas-Linux/Atk-2.20.0/include/atk-1.0/"  LDFLAGS="-L/media/34GB/Arquivos-de-Programas-Linux/xorg/X11-1.4.4/lib/  -L/media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/  -lgtk-x11-2.0" ./configure  --prefix=/media/34GB/Arquivos-de-Programas-Linux/Gimp/Gimp-2.6.0  PKG_CONFIG_PATH=/media/34GB/Arquivos-de-Programas-Linux/Gimp/Babl-0.0.22/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Gimp/Gegl-0.0.22/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Glib-2.32.0/lib/pkgconfig/:/media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/pkgconfig/
    The countless -I used to indicate the include dirs of gtk & cia is precisely because the passing of them through PKG_CONFIG_PATH is not working as intended

    P.S: Anything with "BOTO" on it was added by me.

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Are you really trying to build GIMP 2.6.0 from 2009 ?

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  10. #10
    Registered User
    Join Date
    Sep 2019
    Posts
    15
    Quote Originally Posted by stahta01 View Post
    Are you really trying to build GIMP 2.6.0 from 2009 ?

    Tim S.
    That was the case. I changed it to the 2.6.12, because configure's gtk detection test looks a bit more organized for my personal taste.

    Anyway, I finally had enough time to give a good look in configure's gtk detection test and found at least one "if" clause that is not evaluating as true, and for me it looks like it should:

    Code:
    if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args;
    this should evaluate as true I believe. However, it is clearly not doing so. The values of the variables on the line all seems correct to me:

    Code:
    $PKG_CONFIG
    evaluates to:
    Code:
    /usr/bin/pkg-config
    Code:
    $pkg_config_args
    evaluates to:
    Code:
    gtk+-2.0 gthread-2.0
    and
    Code:
    $min_gtk_version:
    evaluates to:
    Code:
    2.12.5
    as I am passing
    Code:
    /media/34GB/Arquivos-de-Programas-Linux/Gtk+-2.24.20/lib/pkgconfig/
    to the
    Code:
    PKG_CONFIG_PATH
    env variable, the if clause should be evaluating to true, isn't?
    Last edited by colt; 04-15-2023 at 08:00 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. undefined reference to ...
    By DeletedUserAccount in forum C Programming
    Replies: 16
    Last Post: 01-28-2011, 02:27 PM
  2. Undefined reference ?
    By Holymanus in forum C Programming
    Replies: 6
    Last Post: 01-07-2011, 09:15 AM
  3. Undefined reference?
    By Tirith in forum C Programming
    Replies: 8
    Last Post: 08-11-2009, 02:39 PM
  4. undefined reference....
    By najwani in forum C Programming
    Replies: 0
    Last Post: 04-06-2009, 10:05 PM
  5. undefined reference
    By B_Love in forum C++ Programming
    Replies: 6
    Last Post: 09-26-2005, 08:13 AM

Tags for this Thread