Search code examples
octavefltk

octave cannot find fltk XGetUtf8FontAndGlyph symbol


octave 3.8.2 produces this error on loading:

error: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/PKG_ADD: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/__init_fltk__.oct: failed to load: /usr/lib64/fltk/libfltk_gl.so.1.3: undefined symbol: XGetUtf8FontAndGlyph
error: called from:
error:   /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/PKG_ADD at line 6, column 1
GNU Octave, version 3.8.2

I obtain the following information about configuration of graphics libraries

octave:1> octave_config_info().GRAPHICS_LIBS
ans = -L/usr/lib64/fltk -Wl,-rpath,/usr/lib64/fltk -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -lfltk_gl -lGLU -lGL -lfltk -lXcursor -lXfixes -lXext -ldl -lm -lX11

and although no graphic toolkits are evidently loaded initially,

octave:2> available_graphics_toolkits
ans = {}(1x0)

I can register them subsequently,

octave:3> register_graphics_toolkit("gnuplot")
octave:4> available_graphics_toolkits
ans = 
{
  [1,1] = gnuplot
}
octave:5> register_graphics_toolkit("fltk")
octave:6> available_graphics_toolkits
ans = 
{
  [1,1] = fltk
  [1,2] = gnuplot
}

but attempting to load fltk produces an error consistent with the initial warning

octave:7> graphics_toolkit("fltk")
error: feval: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/__init_fltk__.oct: failed to load: /usr/lib64/fltk/libfltk_gl.so.1.3: undefined symbol: XGetUtf8FontAndGlyph
error: called from:
error:   /usr/share/octave/3.8.2/m/plot/util/graphics_toolkit.m at line 74, column 5

and of course attempting to plot anything also fails,

octave:8> plot(1:10)
error: feval: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/__init_fltk__.oct: failed to     load: /usr/lib64/fltk/libfltk_gl.so.1.3: undefined symbol: XGetUtf8FontAndGlyph
error: called from:
error:   /usr/share/octave/3.8.2/m/plot/util/graphics_toolkit.m at line 74, column 5
error: failed to load fltk graphics toolkit
error: base_graphics_toolkit::initialize: invalid graphics toolkit
error:   /usr/share/octave/3.8.2/m/plot/util/figure.m at line 94, column 9
error:   /usr/share/octave/3.8.2/m/plot/util/gcf.m at line 63, column 9
error:   /usr/share/octave/3.8.2/m/plot/util/newplot.m at line 113, column 8
error:   /usr/share/octave/3.8.2/m/plot/draw/plot.m at line 219, column 9

Both octave and fltk were compiled from source under gentoo:

x11-libs/fltk-1.3.3-r2:1  USE="opengl -cairo -debug -doc -examples -games -pdf -static-libs -threads -xft -xinerama"
sci-mathematics/octave-3.8.2:0/3.8.2  USE="X doc glpk gnuplot gui imagemagick opengl qhull qrupdate readline sparse zlib -curl -fftw -hdf5 -java -jit -postscript -static-libs"

resulting in configure switches of (for the fltk library):

./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --includedir=/usr/include/fltk --libdir=/usr/lib64/fltk --docdir=/usr/share/doc/fltk-1.3.3-r2/html --enable-largefile --enable-shared --enable-xdbe --disable-localjpeg --disable-localpng --disable-localzlib --disable-debug --disable-cairo --enable-gl --disable-threads --disable-xft --disable-xinerama

and (for octave)

./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --disable-silent-rules --disable-dependency-tracking --docdir=/usr/share/doc/octave-3.8.2 --enable-shared --disable-static --localstatedir=/var/state/octave --with-blas=-L/usr/lib64/blas/reference -lblas   --with-lapack=-llapack -L/usr/lib64/blas/reference -lblas   --enable-docs --disable-java --enable-gui --disable-jit --enable-readline --without-curl --without-fftw3 --without-fftw3f --disable-fftw-threads --with-glpk --without-hdf5 --with-opengl --with-qhull --with-qrupdate --with-arpack --with-umfpack --with-colamd --with-ccolamd --with-cholmod --with-cxsparse --with-x --with-z --with-magick=GraphicsMagick

If I examine libfltk_gl.so.1.3 with nm, I see that the following symbols are exported:

$ nm -D /usr/lib64/fltk/libfltk_gl.so.1.3
                 U XCreateColormap
                 U XGetUtf8FontAndGlyph
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 w _Jv_RegisterClasses
                 U _Z10fl_measurePKcRiS1_i
000000000000e170 T _Z10gl_descentv
000000000000e590 T _Z10gl_measurePKcRiS1_
... <snip>

According to nm manual, the U designates that the symbol is global (external) but unknown. My question is whether this unknown symbol status is the origin of the error reported from octave, suggesting that the problem lies with how fltk was compiled, or whether the octave compilation is somehow at fault.

Edit: Solved by enabling Xft support: Please see comments below, and I thank Andy again for his help.


Solution

  • XGetUtf8FontAndGlyph should be in libfltk.so.1.3.

    nm -D /usr/lib/x86_64-linux-gnu/libfltk.so.1.3 |grep XGetU
    00000000000c2fc0 T XGetUtf8FontAndGlyph
    

    It's very likely that this is a problem with your configure flags for fltk and not GNU Octave. Just try it with the default settings first.

    You can test if the UTF8 stuff with OpenGL is okay with the "cube" test. Just digg into the fltk-source dir tests:

    cd fltk-1.3.3/test
    make cube && ./cube
    

    Does the text in the lower left of the GL window show up?