Menu

#1764 Wrong link order on ubuntu

None
closed-duplicate
nobody
None
2017-11-17
2016-03-28
No

Seems like the libraries are linked in a wrong order and therefore some dependencies aren't met: On my ubuntu install a build aborts with the following error message:

c++  -g -O2 -I/usr/lib/wx/include/gtk2-unicode-3.1 -I/usr/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2   -lcerf  -o gnuplot alloc.o axis.o breaders.o boundary.o color.o command.o contour.o datablock.o datafile.o dynarray.o eval.o external.o fit.o gadgets.o getcolor.o graph3d.o graphics.o help.o hidden3d.o history.o internal.o interpol.o jitter.o libcerf.o matrix.o misc.o mouse.o multiplot.o parse.o plot.o plot2d.o plot3d.o pm3d.o readline.o save.o scanner.o set.o show.o specfun.o standard.o stats.o stdfn.o tables.o tabulate.o term.o time.o unset.o util.o util3d.o variable.o version.o wxterminal/wxt_gui.o wxterminal/gp_cairo.o wxterminal/gp_cairo_helpers.o  qtterminal/qt_term.o -lreadline  -lncurses  -lz -lgd -lgd -llua5.1  -pthread   -lwx_gtk2u_xrc-3.1 -lwx_gtk2u_html-3.1 -lwx_gtk2u_qa-3.1 -lwx_gtk2u_adv-3.1 -lwx_gtk2u_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1  -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype -lQtNetwork -lQtSvg -lQtGui -lQtCore -ldl -lm -lcerf  -lz -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lcairo -lglib-2.0
/usr/bin/ld: wxterminal/wxt_gui.o: undefined reference to symbol 'XInitThreads'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

Kind regards,

Gunter.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2016-03-29

    The bug is in the pkgconfig files for wxgtk
    It should contain a dependency on -X11, but it doesn't.
    This is mentioned in the gnuplot Release Notes.
    In fact it's the very first thing in the list of known problems:

    • If you configure in the wxt terminal without also configuring in X11,
      you may need to set the environmental variable TERMLIBS:
      TERMLIBS="-lX11" ./configure
     
  • Gunter Königsmann

    wxMaxima doesn't run into this link error. It detects the CFLAGs and LDFLAGs needed in order to compile with wxWidgets the following way:

    AM_OPTIONS_WXCONFIG
    
    AM_PATH_WXCONFIG([3.0.0], [wxWin=1], [wxWin=0], [std,xml,html,adv,aui,core,net,base])
    if test "$wxWin" != 1; then
       AC_MSG_ERROR([
              wxWidgets must be installed on your system.
    
              Please check that wx-config is in path, the directory
              where wxWidgets libraries are installed (returned by
              'wx-config --libs' or 'wx-config --static --libs' command)
              is in LD_LIBRARY_PATH or equivalent variable and
              wxWidgets version is 3.0.0 or above.
              ])
    fi
    
    CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
    CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
    CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
    LIBS="$LIBS $WX_LIBS"
    
    dnl we have to setup rc compiling under 32-bit Windows
    if test x"${win32}" = x"true" ; then
       RC_OBJ="Resources.o"
       wx_prefix=`$WX_CONFIG_NAME --prefix`
       WX_RC_PATH="${wx_prefix}/include"
    else
       RC_OBJ=""
       WX_RC_PATH=""
    fi
    

    The respective portion of src/Makefile.am instead reads:

    wxmaxima_LDADD = $(RC_OBJ) $(WX_LIBS)
    

    This naturally doesn't mean that the package files aren#t utterly broken. And because gnuplot can be compiled without wxWidgets these lines cannot be used 1:1 in gnuplot But perhaps they can be modified to form a workaround...

    If this isn't the case please feel free to close this ticket as "invalid".

    Kind regards,

    Gunter.
    
     
  • Ethan Merritt

    Ethan Merritt - 2016-03-29

    Yes. Gnuplot's automake script does something similar. The problem is that the list of libraries returned by wx-config --libs does not include -lX11 even though at runtime the wx libraries complain and exit if it isn't linked.

     [1] wx-config --libs
    -L/usr/lib64  -lwx_gtk2u_richtext-2.8 -lwx_gtk2u_aui-2.8 -lwx_gtk2u_xrc-2.8 -lwx_gtk2u_qa-2.8 -lwx_gtk2u_html-2.8 -lwx_gtk2u_adv-2.8 -lwx_gtk2u_core-2.8 -lwx_baseu_xml-2.8 -lwx_baseu_net-2.8 -lwx_baseu-2.8 
    

    Gnuplot itself does not need to link to libX11, so the requirement to specify the library for XInitThreads and the run-time failure when it is missing are purely internal to wx. An inevitable runtime failure is worse than a build failure since it's too late to fix thingas at that point. Therefore we added a "useless" call to XInitThreads so that the wx libraries will not error out at run time, but the fallout from that is the build requirement for linkage that you encountered. We reported this problem upstream, but I have not yet encountered a linux release with a fixed wx-config script. Fortunately the work-around is easy - hence the warning in the Release Notes.

     
  • Ethan Merritt

    Ethan Merritt - 2016-03-29

    By the way, this duplicates an earlier bug report trail that originated from a Debian tracker. See gnuplot tracker: https://sourceforge.net/p/gnuplot/bugs/1592/

    I must admit that I have not gone back recently to see if current wx package builds suffer from the same runtime error. It is possible that we can remove the call to XInitThreads again if the wx version is new enough. You could test this by uncommenting this line in config.h

    / wxWidgets >= 2.9 wants calling program to invoke XInit() /
    / #undef WX_NEEDS_XINITTHREADS /

     
  • Gunter Königsmann

    Tried both the git head of wxWidgets (it claims to be 3.1.0) and wxWidgets 3.0.2. Both work fine for me without WX_NEEDS_XINITTHREADS being defined.

    wxMaxima doesn't call XInitThreads on my system and runs. But we've never found out why wxWidgets 3.0.0 failed on Linux while the windows and mac versions worked fine => I assume this might be the reason.

     
  • Ethan Merritt

    Ethan Merritt - 2016-04-04
    • status: open --> pending-duplicate
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2017-11-17
    • Status: pending-duplicate --> closed-duplicate
     

Log in to post a comment.