smlpkg-configpolyml

Compiling Giraffe library Hello World on Ubuntu


I am trying to compile the GTK 3 Hello World Example from the Giraffe Library website.

I installed Poly/ML 5.9.1 from sources, set PATH for the poly executable and LD_LIBRARY_PATH for the libraries. Also, PKG_CONFIG_PATH so that the Makefile would find polyml.pc.

Now I get

$ make polyml
LD_LIBRARY_PATH=/home/gergely/giraffe/lib/polyml:/usr/lib:/home/gergely/local/lib:/usr/lib/x86_64-linux-gnu: \
 GIRAFFE_SML_LIB=/home/gergely/giraffe/lib/sml \
 GIRAFFE_DEBUG=1 \
 /usr/bin/poly --use make-polyml-libs.sml -q
echo "PolyML.export (\"example-1-polyml.o\", main);" > polyml-export.sml
LD_LIBRARY_PATH=/home/gergely/giraffe/lib/polyml:/usr/lib:/home/gergely/local/lib:/usr/lib/x86_64-linux-gnu: \
 GIRAFFE_SML_LIB=/home/gergely/giraffe/lib/sml \
 GIRAFFE_DEBUG=1 \
 /usr/bin/poly --use make-polyml-app.sml -q
cc \
 -g \
 -rdynamic \
 -Wl,--no-copy-dt-needed-entries \
 -Wl,-rpath,/usr/lib \
 -Wl,-rpath,/home/gergely/giraffe/lib/polyml \
 -o example-1-polyml \
 example-1-polyml.o \
 -L/home/gergely/giraffe/lib/polyml -lgiraffe-gobject-2.0 -lgiraffe-gio-2.0 -lgiraffe-gtk-3.0 \
    `PKG_CONFIG_PATH=/usr/lib/pkgconfig:/home/gergely/local/lib/pkgconfig:/usr/lib/x86_64-linux-gnu pkg-config --libs polyml gobject-2.0 gio-2.0 gio-unix-2.0 gtk+-3.0`
    /usr/bin/ld: example-1-polyml.o: warning: relocation in read-only section `.text'
    /usr/bin/ld: example-1-polyml.o:(.data+0x50): undefined reference to `PolyFFIGeneral'
    /usr/bin/ld: example-1-polyml.o:(.data+0x230): undefined reference to `PolyTimingGeneral'
    /usr/bin/ld: example-1-polyml.o:(.data+0x410): undefined reference to `PolyFFIGeneral'
    /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
    collect2: error: ld returned 1 exit status
    make: *** [Makefile:210: example-1-polyml] Error 1

How could I compile this program on my Ubuntu 22.04?


Solution

  • The examples supplied with Giraffe Library do not require PATH, LD_LIBRARY_PATH nor PKG_CONFIG_PATH to be set for Poly/ML. The example Makefile includes ${GIRAFFEHOME}/config.mk which stores the Poly/ML installation found when Giraffe Library was installed. (In the transcript above, it can be seen that LD_LIBRARY_PATH and PKG_CONFIG_PATH are set locally in the build commands produced by the Makefile.)

    From the build commands, I can see that Giraffe Library is using Poly/ML installed under /usr. I suspect this is not the version you built from source (/usr would not be a good prefix for a manually-built version) but is the version provided by the package management system. You need to reinstall Giraffe Library specifying a particular Poly/ML prefix, e.g.

    ./configure --polyml-prefix <polyml-installation-dir>
    make
    make install
    

    I suspect you got this to work not because you used Poly/ML 5.9 but because you reinstalled Giraffe Library which picked up the 5.9 version instead of the system version.

    There is no requirement for your application's Makefile to use ${GIRAFFEHOME}/config.mk. Instead you could require the build environment has suitable values for PATH, LD_LIBRARY_PATH and PKG_CONFIG_PATH.