|
From: Daniel J S. <dan...@ie...> - 2017-07-06 17:38:36
|
On 07/05/2017 05:08 PM, Petr Mikulik wrote: >>>>>> I have troubles compiling rc2 on Linux (OpenSUSE 42.2, and some >>>>>> Ubuntu) linking fails. >>>>>> >>>>>> It is this problem: >>>>>> https://sourceforge.net/p/gnuplot/support-requests/196/ >>>>>> >>>>>> The workaround >>>>>> configure --with-X11 >>>>>> described above does not help, while >>>>>> TERMLIBS="-lX11" ./configure >>>>>> let me gnuplot compile. >>>>>> >>>>>> Can this be fixed? >>>>> >>>>> No. It is a bug in the configuration files distributed for >>>>> libwxgtk. >>>> >>>> Unfortunately it seems to be a wide-spread bug. It is quite >>>> embarassing that a >>>> compile needs googling to fix it locally. >>>> >>>> Cannot "./configure" take care of this? I.e. add the "-lX11" flag if >>>> "something"? >>> >>> That "something" is exactly the problem. Only some versions of >>> wxWidgets need this, and only for some configurations. The >>> wx-config tool is supposed to tell us what libraries are needed so >>> we can link them. But it doesn't mention X11. So how are we to know? >> >> Actually, I think this is gnuplot's responsibility. If I do > >> Anyway, I think gnuplot configure is obligated to add -lX11, given the >> situation. > > I think that ./configure is the place for tests of compile conditions. > There can be some simple case testing whether "-lX11" is needed or not. > Is such a workaround possible? The necessary tests are already present. The hunks of code that matter have pre-processor conditionals: #if defined(WX_NEEDS_XINITTHREADS) && defined(X11) #include <X11/Xlib.h> /* Magic fix for linking against wxgtk3.0 */ #endif and WX_NEEDS_XINITTHREADS and X11 are defined from tests within the configure process. We only want to include library -lX11 for the building of wx_gui.cpp, and there is a convenient definition for that: Makefile:LIBRARIES_FOR_X = -lX11 The included libraries for wx_gui.cpp are gotten from the wx-config command as discussed earlier, and it shows up as Makefile:WX_LIBS = -L/usr/lib/x86_64-linux-gnu -pthread -lwx_gtk2u_xrc-3.0 -lwx_gtk2u_html-3.0 -lwx_gtk2u_qa-3.0 -lwx_gtk2u_adv-3.0 -lwx_gtk2u_core-3.0 -lwx_baseu_xml-3.0 -lwx_baseu_net-3.0 -lwx_baseu-3.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 So, all we really need do is append LIBRARIES_FOR_X to WX_LIBS if XInitThreads() is used in the wx_gui code. If X11 is not present, LIBRARIES_FOR_X should be empty. I've attached a six-line patch to the original bug report associated with the inclusion of XInitThreads() here: https://sourceforge.net/p/gnuplot/bugs/_discuss/thread/94192961/d1c5/attachment/gnuplot-wxlibs_xinitthreads_configure-djs2017jul06.patch Dan |