Libglut.so.3 not found

I recently installed FreeFEM on an Ubuntu 23.04 box. The numerical part seems to work (see example below) but ffglut can’t find the libglut shared library so no graphics.

Obviously this is a system problem not an issue with FreeFEM per se. However, I’d appreciate any help you can give.

FreeFem++ circle.edp

– FreeFem++ v4.13 (Fri 07 Jul 2023 10:49:44 AM CEST - git v4.13)
file : circle.edp
Load: lg_fem lg_mesh lg_mesh3 eigenvalue
1 : // Define mesh boundary
2 : border C(t=0, 2pi){x=cos(t); y=sin(t);}
3 :
4 : // The triangulated domain Th is on the left side of its boundary
5 : mesh Th = buildmesh(C(50));
6 :
7 : // The finite element space defined over Th is called here Vh
8 : fespace Vh(Th, P1);
9 : Vh u, v;// Define u and v as piecewise-P1 continuous functions
10 :
11 : // Define a function f
12 : func f= x
y;
13 :
14 : // Get the clock in second
15 : real cpu=clock();
16 :
17 : // Define the PDE
18 : solve Poisson(u, v, solver=LU)
19 : = int2d(Th)( // The bilinear part
20 : dx(u)*dx(v)
21 : + dy(u)dy(v)
22 : )
23 : - int2d(Th)( // The right hand side
24 : f
v
25 : )
26 : + on(C, u=0); // The Dirichlet boundary condition
27 :
28 : // Plot the result
29 : plot(u);
30 :
31 : // Display the total computational time
32 : cout << "CPU time = " << (clock()-cpu) << endl;
33 : sizestack + 1024 =1920 ( 896 )

– mesh: Nb of Triangles = 434, Nb of Vertices 243
SkyLineMatrix: size pL/pU: 243 3732 3732 moy=15.358
– Solve :
min -0.0103244 max 0.0102905
CPU time = 0.014076
times: compile 0.023038s, execution 0.02644s, mpirank:0
ffglut: error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory
CodeAlloc : nb ptr 3819, size :512928 mpirank: 0
Ok: Normal End

When I check the libraries ffglut wants, it’s clear that the

ldd which ffglut

linux-vdso.so.1 (0x00007ffff4f03000)
libglut.so.3 => not found
libGLU.so.1 => /lib/x86_64-linux-gnu/libGLU.so.1 (0x00007f36fce4f000)
libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f36fcdc8000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f36fcdc3000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f36fca00000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f36fccd8000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f36fccb4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f36fc600000)
libOpenGL.so.0 => /lib/x86_64-linux-gnu/libOpenGL.so.0 (0x00007f36fcc89000)
libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f36fc948000)
libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f36fc916000)
/lib64/ld-linux-x86-64.so.2 (0x00007f36fcfb4000)
libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f36fc4c2000)
libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f36fc8ec000)
libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f36fcc81000)
libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f36fcc79000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f36fc8d7000)
libmd.so.0 => /lib/x86_64-linux-gnu/libmd.so.0 (0x00007f36fc8ca000)

The library is present in /lib/x86_64-linux-gnu/ and I installed in the usual way with sudo apt install libglut3-dev (below)

file libglut.so

libglut.so: symbolic link to libglut.so.3.12

file libglut.so.3.12

libglut.so.3.12: symbolic link to libglut.so.3.12.0

file libglut.so.3.12.0

libglut.so.3.12.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=1e0834454deb9f0c288de8a2bfef4d469880cb3a, stripped

sudo apt install freeglut3

Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
E: Unable to locate package freeglut3

sudo apt install freeglut3-dev

Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
freeglut3-dev is already the newest version (3.4.0-1).
0 upgraded, 0 newly installed, 0 to remove and 28 not upgraded.

I thought the library might not be in one of the expected locations but

ls /etc/ld.so.conf.d/

fakeroot-x86_64-linux-gnu.conf libc.conf x86_64-linux-gnu.conf zz_i386-biarch-compat.conf

cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf

Multiarch support

/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

I’ve run sudo ldconfig, updated all packages, tried the binary, and compiled from source (with successful ‘make -j4 check’).

Any idea what I should to resolve this problem of a shared library that’s not found at runtime?

You could try adding the path to the library using the environment variable LD_LIBRARY_PATH.

That’s a good suggestion. It should work but I don’t see any effect.

. ~/.bashrc

echo $LD_LIBRARY_PATH

/lib/x86_64-linux-gnu/

ls $LD_LIBRARY_PATH/libglut*

/lib/x86_64-linux-gnu//libglut.a /lib/x86_64-linux-gnu//libglut.so.3.12
/lib/x86_64-linux-gnu//libglut.so /lib/x86_64-linux-gnu//libglut.so.3.12.0

FreeFem++ circle.edp

– FreeFem++ v4.13 (Fri 07 Jul 2023 10:49:44 AM CEST - git v4.13)
file : circle.edp
Load: lg_fem lg_mesh lg_mesh3 eigenvalue
1 : // Define mesh boundary
2 : border C(t=0, 2*pi){x=cos(t); y=sin(t);}

ffglut: error while loading shared libraries: libglut.so.3: cannot open shared object file: No such file or directory
CPU time = 0.011335
times: compile 0.040346s, execution 0.025853s, mpirank:0
CodeAlloc : nb ptr 3819, size :512928 mpirank: 0
Ok: Normal End

Here’s a thread of a similar issue in which the LD_LIBRARY_PATH idea worked. My situation mirrors this problem but I haven’t been able to get their solution to work.

I downloaded the source for freeglut (link below), make, make install, ldconfig and it works now.

I couldn’t install the freeglut3 package (via apt) this whole time but freeglut3-dev was no problem. I added universe and a few other repositories but I just couldn’t get apt to install the package.

https://freeglut.sourceforge.net/docs/install.php