Building GtkAda git master on OpenSuSE Tumbleweed

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Building GtkAda git master on OpenSuSE Tumbleweed

Oliver Kellogg-3
Hi,

Here are some experiences I had while building GtkAda on Tumbleweed.

Tumbleweed comes with the following GNAT:
$ gnatls --version
GNATLS 6.1.1 20160707 [gcc-6-branch revision 238088]
Copyright (C) 1992-2016, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Apparently `gprbuild` and `gprinstall` are not included in the FSF compiler.
I downloaded the gprbuild from GPL-2016 and after installation in /usr did the following:
$ su
$ cd /usr/bin
$ mv gprbuild gprbuld-2016
$ echo -e '#!/bin/bash\ngprbuild-2016 --RTS=/usr/lib64/gcc/x86_64-suse-linux/6 $*' > gprbuild
$ chmod a+x gprbuild
$ mv gprinstall gprinstall-2016
$ echo -e '#!/bin/bash\ngprinstall-2016 --RTS=/usr/lib64/gcc/x86_64-suse-linux/6 $*' > gprinstall
$ chmod a+x gprinstall

`configure` was then happy; however, during `make` there was an error compiling src/opengl/gtkglarea.c:

In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9:0,
                 from /usr/include/glib-2.0/glib/gtypes.h:32,
                 from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from /home/okellogg/tools/gtkada/src/opengl/gdkgl.h:23,
                 from /home/okellogg/tools/gtkada/src/opengl/gtkglarea.c:22:
/usr/include/gtk-3.0/gtk/gtk-autocleanups.h:86:31: error: unknown type name ‘GtkGLArea’
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkGLArea, g_object_unref)

I realized I should check what version of gtk is installed:
$ pkg-config gtk+-3.0 --modversion
3.20.6

AFAICT GtkAda currently is tested with gtk 3.14 ...

Since I am not using the Gtk openGL stuff I got adventurous and made the following change (hack alert!)

diff --git a/src/opengl/gtkglarea.h b/src/opengl/gtkglarea.h
index 5037b30..7f9b54a 100644
--- a/src/opengl/gtkglarea.h
+++ b/src/opengl/gtkglarea.h
@@ -21,6 +21,8 @@
 #ifndef __GTK_GL_AREA_H__
 #define __GTK_GL_AREA_H__

+typedef struct _GtkGLArea       GtkGLArea;
+
 #include <gdk/gdk.h>
 #include <gdkgl.h>
 #include <gtk/gtk.h>
@@ -36,7 +38,6 @@ G_BEGIN_DECLS
 #define GTK_GL_AREA_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_GL_AREA, GtkGLArea))


-typedef struct _GtkGLArea       GtkGLArea;
 typedef struct _GtkGLAreaClass  GtkGLAreaClass;


With that change, compilation proceeded for a while but then I got another error:

gcc -shared -o /home/okellogg/tools/gtkada/src/lib/gtkada/relocatable/libgtkada.so.17.0w ... @/home/okellogg/tools/gtkada/src/obj/gtkada/relocatable/GNAT-TEMP-000006.TMP
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lgnat-6.1
collect2: error: ld returned 1 exit status
gprlib: /usr/bin/gcc execution error
gprbuild: could not build library for project gtkada
make: *** [Makefile:85: build_library_type/relocatable] Error 4

I guess that is a missing soft link in openSuSE's GNAT installation:

sudo ln -s /usr/lib64/libgnat-6.so /usr/lib64/libgnat-6.1.so

libgtkada.so could then be linked.
After a while there was yet another error:

gcc -c b__testgtk.adb
ar cr libtestgtk.a ...
ranlib libtestgtk.a
gcc testgtk.o -lGLU -lGL -L/home/okellogg/tools/gtkada//lib -L/home/okellogg/tools/gtkada//bin -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lfontconfig -lfreetype -o testgtk
gcc test_rtree.o -lGLU -lGL -L/home/okellogg/tools/gtkada//lib -L/home/okellogg/tools/gtkada//bin -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lfontconfig -lfreetype -o test_rtree
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: libtestgtk.a(lw.o): undefined reference to symbol 'sqrtf@@GLIBC_2.2.5'
/lib64/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
gprbuild: link of testgtk.adb failed
make: *** [Makefile:98: tests] Error 4

In shared.gpr at the generated definition of Gtk_Libs, I manually added "-lm":

gcc testgtk.o -lGLU -lGL -L/home/okellogg/tools/gtkada//lib -L/home/okellogg/tools/gtkada//bin -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lfontconfig -lfreetype -lm -o testgtk
gcc test_rtree.o -lGLU -lGL -L/home/okellogg/tools/gtkada//lib -L/home/okellogg/tools/gtkada//bin -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lfontconfig -lfreetype -lm -o test_rtree
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: /home/okellogg/tools/gtkada/src/lib/gtkada_gl/static/libgtkada_gl.a(gdkgl.o): undefined reference to symbol 'XFree'
/usr/lib64/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Again in shared.gpr at Gtk_Libs I added "-lX11" and then the build went successful.

This GtkAda build has been working fine for my purposes.

Oliver

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: Building GtkAda git master on OpenSuSE Tumbleweed

Emmanuel Briot
> Since I am not using the Gtk openGL stuff I got adventurous and made the following change (hack alert!)

Seems like you might want to simply use

   ./configure --without-GL  --prefix=...

when you configure, to disable openGL support altogether, rather than the "hack" you just did.


> With that change, compilation proceeded for a while but then I got another error:
>
> gcc -shared -o /home/okellogg/tools/gtkada/src/lib/gtkada/relocatable/libgtkada.so.17.0w ... @/home/okellogg/tools/gtkada/src/obj/gtkada/relocatable/GNAT-TEMP-000006.TMP
> /usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lgnat-6.1
> collect2: error: ld returned 1 exit status
> gprlib: /usr/bin/gcc execution error
> gprbuild: could not build library for project gtkada
> make: *** [Makefile:85: build_library_type/relocatable] Error 4
>
> I guess that is a missing soft link in openSuSE's GNAT installation:

Seems like an installation issue here.

> Again in shared.gpr at Gtk_Libs I added "-lX11" and then the build went successful.

Strange that this would not be included by pkg-config, though. We cannot hard-code this in
GtkAda, since gtk+ doesn't depend on X11 for all supported systems.

Thanks for the feedback

Emmanuel

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: Building GtkAda git master on OpenSuSE Tumbleweed

Oliver Kellogg-3
> Seems like you might want to simply use
>
>    ./configure --without-GL  --prefix=...

Yes indeed, thanks for the hint.

Also, due to a posting by Simon Wright on comp.lang.ada I realized that gprbuild is on GitHub.
Next time, I will try building that instead of resorting to the GPL distro.

Oliver


-----Original Message-----
Subject: Re: [gtkada] Building GtkAda git master on OpenSuSE Tumbleweed
Date: 2016-08-16T14:55:27+0200
From: "Emmanuel Briot" <[hidden email]>
To: "Oliver Kellogg" <[hidden email]>

> Since I am not using the Gtk openGL stuff I got adventurous and made the following change (hack alert!)

Seems like you might want to simply use

   ./configure --without-GL  --prefix=...

when you configure, to disable openGL support altogether, rather than the "hack" you just did.


> With that change, compilation proceeded for a while but then I got another error:
>
> gcc -shared -o /home/okellogg/tools/gtkada/src/lib/gtkada/relocatable/libgtkada.so.17.0w ... @/home/okellogg/tools/gtkada/src/obj/gtkada/relocatable/GNAT-TEMP-000006.TMP
> /usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lgnat-6.1
> collect2: error: ld returned 1 exit status
> gprlib: /usr/bin/gcc execution error
> gprbuild: could not build library for project gtkada
> make: *** [Makefile:85: build_library_type/relocatable] Error 4
>
> I guess that is a missing soft link in openSuSE's GNAT installation:

Seems like an installation issue here.

> Again in shared.gpr at Gtk_Libs I added "-lX11" and then the build went successful.

Strange that this would not be included by pkg-config, though. We cannot hard-code this in
GtkAda, since gtk+ doesn't depend on X11 for all supported systems.

Thanks for the feedback

Emmanuel


_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: Building GtkAda git master on OpenSuSE Tumbleweed

Björn Persson-3
In reply to this post by Oliver Kellogg-3
Oliver Kellogg <[hidden email]> wrote:
> /usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lgnat-6.1
[...]
> I guess that is a missing soft link in openSuSE's GNAT installation:
>
> sudo ln -s /usr/lib64/libgnat-6.so /usr/lib64/libgnat-6.1.so

In Fedora we have patched GPRlib to link with "-lgnat-6" instead:

--- a/src/gprlib.adb
+++ b/src/gprlib.adb
@@ -22,6 +22,7 @@
 
 with Ada.Command_Line;  use Ada.Command_Line;
 with Ada.Text_IO;       use Ada.Text_IO;
+with Ada.Strings.Fixed;
 
 with GNAT.Case_Util;            use GNAT.Case_Util;
 with GNAT.Directory_Operations; use GNAT.Directory_Operations;
@@ -1154,6 +1155,25 @@ begin
                      GNAT_Version := new String'(Line (6 .. Last));
                      GNAT_Version_Set := True;
 
+                     -- The version numbering scheme changed in GCC 5.
+                     -- If there is a dot in the version, and the part before
+                     -- the dot is 5 or greater, then use only that part in the
+                     -- library names.
+
+                     declare
+                        Pos : Natural := Ada.Strings.Fixed.Index (Line, ".", 6);
+                     begin
+                        if Pos > 0 then
+                           Pos := Pos - 1;  -- the last digit in the first part
+                           if Natural'Value (Line(6 .. Pos)) >= 5 then
+                              Last := Pos;
+                           end if;
+                        end if;
+                     exception
+                        when Constraint_Error =>
+                           null;  -- Not a number? Then let it be.
+                     end;
+
                      Libgnat :=
                        new String'
                          ("-lgnat-" & Line (6 .. Last));


> In shared.gpr at the generated definition of Gtk_Libs, I manually
> added "-lm":

I have to add -lm in Fedora too. Does anyone happen to know whether libm
is universally separate from libc, or whether that's a GNU-specific
thing? If it's universal, then -lm should simply be hard-coded in
TestGTK.

Björn Persson

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada

attachment0 (836 bytes) Download Attachment