Trouble compiling visualization libraries

Dear all,

ROOT was installed on my local machine with conda create -c conda-forge --name DirectFlow root.
I am trying to compile this code, within the newly created environment, as follows:

g++ v1_beam.cc `root-config --cflags --ldflags --evelibs`

but am getting

/home/bruno/miniconda3/envs/DirectFlow/lib/libEve.so: undefined reference to `glColorMaterial'
/home/bruno/miniconda3/envs/DirectFlow/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /home/bruno/miniconda3/envs/DirectFlow/lib/libRGL.so: undefined reference to `glXMakeCurrent'
/home/bruno/miniconda3/envs/DirectFlow/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: /home/bruno/miniconda3/envs/DirectFlow/lib/libRGL.so: undefined reference to `glDeleteLists'
(...)

I tried to add specific OpenGL-related libraries (such as -lGLU) found by running:

ls /home/bruno/miniconda3/envs/DirectFlow/lib | grep -i gl

to no avail. The same code, after removig its main(), runs successfully in the ROOT terminal with root; .x v1_beam.cc. What am I missing?


ROOT Version: 6.24/00
Platform: Ubuntu 20.04.2 LTS
Compiler: gcc version 9.3.0 (crosstool-NG 1.24.0.133_b0863d8_dirty)


g++ v1_beam.cc `root-config --cflags --ldflags --evelibs`

Thsi should be sufficient to make it work. Maybe @matevz has an idea what could be missing…

Hmmh, I don’t know how coda stuff works and what packages are included in there, but indeed you seem to be missing libGL and libglx … and probably libGLU as well. Have you added -L for the linker path?

\m

The command root-config --cflags --ldflags --evelibs outputs

-pthread -std=c++17 -m64 -I/home/bruno/miniconda3/envs/DirectFlow/include -m64 -L/home/bruno/miniconda3/envs/DirectFlow/lib -lEve -lEG -lGeom -lGed -lRGL -lGui -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -Wl,-rpath,/home/bruno/miniconda3/envs/DirectFlow/lib -pthread -lm -ldl -rdynamic

so libGL, libglx and libGLU are not included. If I specifically add them with

g++ v1_beam.cc `root-config --cflags --ldflags --evelibs` -lGLU -lglx -lGL -o df.exe

I get

/home/bruno/miniconda3/envs/DirectFlow/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: cannot find -lglx
/home/bruno/miniconda3/envs/DirectFlow/bin/../lib/gcc/x86_64-conda-linux-gnu/9.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: cannot find -lGL

Indeed, ls /home/bruno/miniconda3/envs/DirectFlow/lib | grep -i gl outputs

-rwxrwxr-x  2 bruno bruno   1MB Mar 29  2020 libGLU.so.1.3.1
-rw-rw-r--  2 bruno bruno   2MB Dec  4  2020 libGLEW.a
-rwxrwxr-x  2 bruno bruno   1MB Dec  4  2020 libGLEW.so.2.1.0
-rwxrwxr-x  2 bruno bruno   1MB Dec  5  2020 libftgl.so.2.4.0
-rwxrwxr-x  2 bruno bruno   1MB Dec  5  2020 libgl2ps.so.1.4.2
-rwxrwxr-x  2 bruno bruno   1MB Jan 10 18:00 libxcb-glx.so.0.0.0
-rw-rw-r--  2 bruno bruno   6MB Jun  4 15:30 RGL.pcm
-rwxrwxr-x  2 bruno bruno   3MB Jun  4 15:40 libRGL.so.6.24.00
-rwxrwxr-x  1 bruno bruno   2MB Jul  1 10:26 libglib-2.0.so.0.6800.3
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libGLU.so.1 -> libGLU.so.1.3.1
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libGLU.so -> libGLU.so.1.3.1
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libxcb-glx.so.0 -> libxcb-glx.so.0.0.0
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libxcb-glx.so -> libxcb-glx.so.0.0.0
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libgl2ps.so.1 -> libgl2ps.so.1.4.2
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libgl2ps.so -> libgl2ps.so.1.4.2
drwxrwxr-x  3 bruno bruno   1MB Jul  1 10:26 glib-2.0/
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libglib-2.0.so.0 -> libglib-2.0.so.0.6800.3
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libftgl.so.1 -> libftgl.so.2.4.0
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libftgl.so -> libftgl.so.2.4.0
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libGLEW.so.2.1 -> libGLEW.so.2.1.0
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libGLEW.so -> libGLEW.so.2.1.0
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libRGL.so.6.24 -> libRGL.so.6.24.00
lrwxrwxrwx  1 bruno bruno   1MB Jul  1 10:26 libRGL.so -> libRGL.so.6.24.00

where only libGLU is present.

I also tried to explicitly include the glib2.0 folder and some OpenGL-related packages, but again without success, being the error message the same:

g++ v1_beam.cc `root-config --cflags --ldflags --evelibs` -I/home/bruno/miniconda3/envs/DirectFlow/lib/glib-2.0/include/ -lGLU -lxcb-glx -lGLEW -lftgl -o df.exe

This might be relevant: conda's gcc can't find OpenGL · Issue #2170 · conda/conda · GitHub

Well, where are libGL and libglx supposed to be coming from? :slight_smile:

@bellenot I do not see how the information there can be used in this case.
@matevz I did not understand your comment, sorry for that.

I managed to compile the code (using the GL libraries available outside conda), but I immediately get a segmentation violation. Here you have a MRE:

#include <iostream>
#include "TEveManager.h"

int main() {
  TEveManager::Create();
  return 0;
}

which I compiled with

g++ mwe.cc `root-config --cflags --ldflags --evelibs` -lMinuit -I/home/bruno/miniconda3/envs/DirectFlow/include/ -L/usr/lib/x86_64-linux-gnu/ -lGL -lGLdispatch -lGLX -lGLU -lxcb-glx -lGLEW -lftgl -lrt -pthread -lresolv -o mwe.ex

and which, upon running, gives

> ./mwe.exe 

 *** Break *** segmentation violation

Try with:

#include <TEveManager.h>
#include <TApplication.h>

int main(int argc, char **argv)
{
   TApplication myapp("myapp", &argc, argv);
   TEveManager::Create();
   myapp.Run();
   return 0;
}

It worked!

For future reference, this is the command required to compile the application:

g++ v1_beam.cc `root-config --cflags --ldflags --evelibs` -lMinuit -lrt -I/home/bruno/miniconda3/envs/DirectFlow/include/ -L/usr/lib/x86_64-linux-gnu/ -lGL -lGLX -lGLdispatch -o df.exe

Some questions:

  • The above solution is not really satisfactory; I would expect the missing OpenGL packages to be already included. I am using software belonging to different “environments”, which can lead to conflicts later on.
  • If TApplication is really required, is it possible for TEveManager to throw an error when an instance of TApplication has not been previously created?
  • As a side note, TFitter requires -lMinuit. Can the latter be included somewhere in root-config --cflags --ldflags --glibs?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.