GLVis: Erro do vinculador “referência indefinida ao símbolo 'XGetWindowAttributs'”

2

Estou tentando instalar o GLVis que tem uma longa lista de dependências (veja o final do post), todas as quais eu instalei, via apt-get ou compilação manual. No entanto, estou recebendo um erro de vinculador ao tentar criar o GLVis. Especificamente, uma referência indefinida ao símbolo ' XGetWindowAttributes ':

stan@ubuntu:~/Downloads/glvis-3.1$ make
g++ -O3 -I../mfem-3.3.2 -DGLVIS_MULTISAMPLE=4 -DGLVIS_MS_LINEWIDTH=1.4 -I/usr/include -DGLVIS_USE_LIBPNG -DGLVIS_USE_FREETYPE -I/usr/include/freetype2 -o glvis glvis.cpp -Llib -lglvis -L../mfem-3.3.2 -lmfem -lrt -L -lX11 -lGL -lGLU -lpng -lfreetype -lfontconfig -lpthread
/usr/bin/x86_64-linux-gnu-ld: lib/libglvis.a(aux_vis.o): undefined reference to symbol 'XGetWindowAttributes'
//usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
makefile:187: recipe for target 'glvis' failed
make: *** [glvis] Error 1

make não retornou nenhum outro erro, então suponho que não tenha faltado fornecer nenhuma das bibliotecas necessárias. Depois de um bom tempo limpando e reinstalando os pacotes, escolhi pedir sua ajuda, já que não posso nem saber se a falha está do meu lado. Eu tenho muito pouco conhecimento sobre os internos do Ubuntu e X11 e eu ficaria muito grato pela sua gentil ajuda.

Como eu poderia tentar resolver esse problema? Esse erro em particular apareceu para outras pessoas em contextos com os quais não posso me relacionar e tentar as soluções deles, se aplicável, não me levou a nenhum lugar.

Estou em uma máquina virtual usando o Ubuntu 18.04 64bits.

As instruções para instalar o estado do GLVis:

GLVis is an X11 application and can be built on Linux/Unix systems including Mac OS X using the X11/XQuarz app and under Windows using Cygwin/X.

Besides a C++ compiler, GLVis depends on the following external packages:

  • the MFEM library (use the latest release) plus any libraries that MFEM was built to depend on mfem.org

  • the X11, GL and GLU libraries x.org, opengl.org, mesa3d.org

  • the libpng or libtiff library; used for taking screenshots (optional) libpng.org, libtiff.org

  • the FreeType 2 and Fontconfig libraries; used for font rendering (optional) freetype.org, fontconfig.org

There are two build systems, one based on GNU make and one based on CMake, as described below. Choose the one that matches the build system you used to build MFEM.

    
por Jersey 11.05.2018 / 21:57

1 resposta

1

O problema está em uma variável de ambiente antiga que não é mais usada no Ubuntu 18.04 LTS, chamada $ X11_LIB_DIR . Isso não avalia nada, e quebra o compilador mpicc quando -L é usado.

Veja abaixo:

mpicxx -O3 -I../mfem -I../mfem/../hypre-2.10.0b/src/hypre/include -DGLVIS_MULTISAMPLE=4 -DGLVIS_MS_LINEWIDTH=1.4 -I/usr/include -DGLVIS_USE_LIBPNG -DGLVIS_USE_FREETYPE -I/usr/include/freetype2 -o glvis glvis.cpp -Llib -lglvis -L../mfem -lmfem -L../mfem/../hypre-2.10.0b/src/hypre/lib -lHYPRE -L../mfem/../metis-4.0 -lmetis -lrt -L -lX11 -lGL -lGLU -lpng -lfreetype -lfontconfig -lpthread

Observe o aleatório "- L" antes de "- lX11" ?

Deve ser assim:

mpicxx -O3 -I../mfem -I../mfem/../hypre-2.10.0b/src/hypre/include -DGLVIS_MULTISAMPLE=4 -DGLVIS_MS_LINEWIDTH=1.4 -I/usr/include -DGLVIS_USE_LIBPNG -DGLVIS_USE_FREETYPE -I/usr/include/freetype2 -o glvis glvis.cpp -Llib -lglvis -L../mfem -lmfem -L../mfem/../hypre-2.10.0b/src/hypre/lib -lHYPRE -L../mfem/../metis-4.0 -lmetis -lrt -lX11 -lGL -lGLU -lpng -lfreetype -lfontconfig -lpthread

Então, para corrigir isso, altere a linha # 121 no makefile para ler:

GL_LIBS = -lX11 -lGL -lGLU
    
por Tuxprogrammer 16.05.2018 / 22:33