1
votes

(Crossposting from comp.lang.ada)

I am following the plugin scheme from the GNAT examples, using GTK. So I need gtkada, and for proper tasking with that, gtkada_contributions. From the Adacore site I grabbed the actual versions (2020) of (binary) GNAT and gtkada. From Dmitry's site I took the gtkada_contributions source code.

The plugin scheme demands building standalone relocatable libraries (loaded at runtime). So for making (on Linux) I call from a terminal:

   gtkada-env.sh
   export GTKADA_BUILD=relocatable
   gprbuild -Pbase

My project file base.gpr withs gtkada_contributions_lib.gpr, which is the original project file with the following additions:

   for Library_Name use "gtkada_contributions";
   for Library_Dir use "lib";
   for Library_Kind use "relocatable";

The above gprbuild command now produces:

Build Libraries
[gprlib]       gtkada_contributions.lexch
[link library] libgtkada_contributions.so
/opt/GNAT/2020/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.1/ld: /home/frank/Lib/Ada/gtkada_contributions/gdk-color-ihls.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/GNAT/2020/bin/../libexec/gcc/x86_64-pc-linux-gnu/9.3.1/ld: /home/frank/Lib/Ada/gtkada_contributions/gdk-pixbuf-image.o: relocation R_X86_64_32 against symbol `gdk__pixbuf__image__rgb_imageT' can not be used when making a shared object; recompile with -fPIC

...

and a lot of other, similar lines.

Adding -fPIC to gtkada_contributions_lib.gpr (compiler switches) didn't change anything, so I guess it is gtkada or even gtk which has to be recompiled. Going ahead alone probably means hours of useless work with the possible result of breaking my system.

So how can I compile/link my project? Will then future projects without relocatable libraries still compile and link?

Thanks in advance for any hint.

1
As far I know, GtkAda is distributed in 3 versions: static, static-pic and relocatable. Question: are you sure that your compiler doesn't add anywhere flag -fPIC during compilation? Or -static flag? Because it probably is trying to call static-pic version. Just run gprbuild with flag -vh to get a lot more information.thindil
For 64 bit linux the community section contains a source and a bin version of gtkada. I downloaded bin. It must contain source code too, because I saw a lot of compile messages upon executing the install script. I don't remember to have been asked anything besides the target directory.hreba
That's very weird. I was testing gtkada_contributions on almost identical set (also GNAT GPL 2020 and GTKAda 2020) on Ubuntu and everything works as expected. If I remember correctly, some distributions adds they own flags to compilers (by .bashrc, environment variables etc. things). Some time ago, -fPIC for example was added by default by Debian or Fedora. I'm not sure now which one.thindil
After reinstalling GNAT and gtkada without avail, I had one more look at the error messages and gtkada_contributions directory. It seems there were object files laying around from earlier compilation attempts without -fPIC, and there occured no recompilation after inserting this flag in the project file. After recompilation with the -f flag (force), it worked. Problem resolved, thanks for sharing your observations.hreba

1 Answers

1
votes

Finally got it. It seems that gtkada_contributions weren't recompiled after adding the -fPIC switch to the project file. After including the -f flag (force) in the gprbuild command, everything was compiled without error.