rgl icon indicating copy to clipboard operation
rgl copied to clipboard

Installation problem: gcc -o conftest -g -O2 -DHAVE_PNG_H -I/usr/include/libpng16 conftest.c -lGL -lpng16 -lX11 >&5 /usr/bin/ld: cannot find -lGL

Open csaybar opened this issue 2 years ago • 5 comments

Hi, thank you for this fantastic package!.

I had a lot of problem trying to fully install rgl on my system.

What I did:

I install without problems:

aptitude install libgl1-mesa-dev libglu1-mesa-dev

However in compiling time I got this warning:

install.packages("rgl")
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for gcc... (cached) gcc -std=gnu99
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc -std=gnu99 accepts -g... (cached) yes
checking for gcc -std=gnu99 option to accept ISO C89... (cached) none needed
checking for libpng-config... yes
configure: using libpng-config
configure: using libpng dynamic linkage
checking for X... libraries , headers 
checking for XAllocClassHint... yes
checking GL/gl.h usability... yes
checking GL/gl.h presence... yes
checking for GL/gl.h... yes
checking GL/glu.h usability... yes
checking GL/glu.h presence... yes
checking for GL/glu.h... yes
checking for glEnd in -lGL... no   ------- <PROBLEM SEEMS TO BE HERE!>
configure: WARNING: missing required library GL
configure: compiling without OpenGL support
configure: creating ./config.status
config.status: creating R/noOpenGL.R
config.status: creating src/useNULL/Makevars
config.status: creating src/Makevars

To get more information about what was happening I run ./configure by manually downloading the package from CRAN. I attached the config.log

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by configure, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ ./configure 

## --------- ##
## Platform. ##
## --------- ##

hostname = csaybar-pc01
uname -m = x86_64
uname -r = 5.8.0-63-generic
uname -s = Linux
uname -v = #71-Ubuntu SMP Tue Jul 13 15:59:12 UTC 2021

/usr/bin/uname -p = x86_64
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /home/csaybar/miniconda3/bin
PATH: /home/csaybar/.poetry/bin
PATH: /home/csaybar/.local/bin
PATH: /home/csaybar/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games
PATH: /usr/local/games
PATH: /snap/bin
PATH: /home/csaybar/.dotnet/tools
PATH: /usr/local/MATLAB/MATLAB_Runtime/v96/runtime/glnxa64
PATH: /usr/local/MATLAB/MATLAB_Runtime/v96/bin/glnxa64
PATH: /usr/local/MATLAB/MATLAB_Runtime/v96/sys/os/glnxa64
PATH: /usr/local/MATLAB/MATLAB_Runtime/sys/opengl/lib/glnxa64


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2204: checking for gcc
configure:2220: found /usr/bin/gcc
configure:2231: result: gcc
configure:2460: checking for C compiler version
configure:2469: gcc --version >&5
gcc (Ubuntu 10.3.0-1ubuntu1~20.10) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:2480: $? = 0
configure:2469: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.3.0-1ubuntu1~20.10' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-poYruo/gcc-10-10.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-poYruo/gcc-10-10.3.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.10) 
... rest of stderr output deleted ...
configure:2480: $? = 0
configure:2469: gcc -V >&5
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:2480: $? = 1
configure:2469: gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:2480: $? = 1
configure:2500: checking whether the C compiler works
configure:2522: gcc    conftest.c  >&5
configure:2526: $? = 0
configure:2574: result: yes
configure:2577: checking for C compiler default output file name
configure:2579: result: a.out
configure:2585: checking for suffix of executables
configure:2592: gcc -o conftest    conftest.c  >&5
configure:2596: $? = 0
configure:2618: result: 
configure:2640: checking whether we are cross compiling
configure:2648: gcc -o conftest    conftest.c  >&5
configure:2652: $? = 0
configure:2659: ./conftest
configure:2663: $? = 0
configure:2651: result: no
configure:2656: checking for suffix of object files
configure:2678: gcc -c   conftest.c >&5
configure:2682: $? = 0
configure:2703: result: o
configure:2707: checking whether we are using the GNU C compiler
configure:2726: gcc -c   conftest.c >&5
configure:2726: $? = 0
configure:2735: result: yes
configure:2744: checking whether gcc accepts -g
configure:2764: gcc -c -g  conftest.c >&5
configure:2764: $? = 0
configure:2805: result: yes
configure:2822: checking for gcc option to accept ISO C89
configure:2885: gcc  -c -g -O2  conftest.c >&5
configure:2885: $? = 0
configure:2898: result: none needed
configure:2923: checking how to run the C preprocessor
configure:2954: gcc -E  conftest.c
configure:2954: $? = 0
configure:2968: gcc -E  conftest.c
conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory
    9 | #include <ac_nonexistent.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
configure:2968: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| #include <ac_nonexistent.h>
configure:2993: result: gcc -E
configure:3013: gcc -E  conftest.c
configure:3013: $? = 0
configure:3027: gcc -E  conftest.c
conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory
    9 | #include <ac_nonexistent.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.
configure:3027: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| #include <ac_nonexistent.h>
configure:3103: checking for gcc
configure:3130: result: gcc
configure:3359: checking for C compiler version
configure:3368: gcc --version >&5
gcc (Ubuntu 10.3.0-1ubuntu1~20.10) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3379: $? = 0
configure:3368: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.3.0-1ubuntu1~20.10' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-poYruo/gcc-10-10.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-poYruo/gcc-10-10.3.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.10) 
... rest of stderr output deleted ...
configure:3379: $? = 0
configure:3368: gcc -V >&5
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3379: $? = 1
configure:3368: gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:3379: $? = 1
configure:3383: checking whether we are using the GNU C compiler
configure:3411: result: yes
configure:3420: checking whether gcc accepts -g
configure:3481: result: yes
configure:3498: checking for gcc option to accept ISO C89
configure:3574: result: none needed
configure:3631: checking for libpng-config
configure:3647: found /usr/bin/libpng-config
configure:3659: result: yes
configure:3670: using libpng-config
configure:3674: using libpng dynamic linkage
configure:4042: checking for X
configure:4150: gcc -E  -DHAVE_PNG_H -I/usr/include/libpng16 conftest.c
configure:4150: $? = 0
configure:4181: gcc -o conftest -g -O2  -DHAVE_PNG_H -I/usr/include/libpng16  conftest.c -lX11  -lpng16 >&5
configure:4181: $? = 0
configure:4231: result: libraries , headers 
configure:4256: checking for XAllocClassHint
configure:4256: gcc -o conftest -g -O2  -DHAVE_PNG_H -I/usr/include/libpng16  conftest.c  -lpng16 -lX11 >&5
configure:4256: $? = 0
configure:4256: result: yes
configure:4281: checking GL/gl.h usability
configure:4281: gcc -c -g -O2  -DHAVE_PNG_H -I/usr/include/libpng16 conftest.c >&5
configure:4281: $? = 0
configure:4281: result: yes
configure:4281: checking GL/gl.h presence
configure:4281: gcc -E  -DHAVE_PNG_H -I/usr/include/libpng16 conftest.c
configure:4281: $? = 0
configure:4281: result: yes
configure:4281: checking for GL/gl.h
configure:4281: result: yes
configure:4281: checking GL/glu.h usability
configure:4281: gcc -c -g -O2  -DHAVE_PNG_H -I/usr/include/libpng16 conftest.c >&5
configure:4281: $? = 0
configure:4281: result: yes
configure:4281: checking GL/glu.h presence
configure:4281: gcc -E  -DHAVE_PNG_H -I/usr/include/libpng16 conftest.c
configure:4281: $? = 0
configure:4281: result: yes
configure:4281: checking for GL/glu.h
configure:4281: result: yes
configure:4324: checking for glEnd in -lGL
configure:4349: gcc -o conftest -g -O2  -DHAVE_PNG_H -I/usr/include/libpng16  conftest.c -lGL   -lpng16 -lX11 >&5
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
configure:4349: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define HAVE_GL_GL_H 1
| #define HAVE_GL_GLU_H 1
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char glEnd ();
| int
| main ()
| {
| return glEnd ();
|   ;
|   return 0;
| }
configure:4359: result: no
configure:4372: WARNING: missing required library GL
configure:4577: compiling without OpenGL support
configure:4742: creating ./config.status

## ---------------------- ##
## Running config.status. ##
## ---------------------- ##

This file was extended by config.status, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  CONFIG_FILES    = 
  CONFIG_HEADERS  = 
  CONFIG_LINKS    = 
  CONFIG_COMMANDS = 
  $ ./config.status 

on csaybar-pc01

config.status:728: creating R/noOpenGL.R
config.status:728: creating src/useNULL/Makevars
config.status:728: creating src/Makevars

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_c_compiler_gnu=yes
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_XMKMF_set=
ac_cv_env_XMKMF_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_func_XAllocClassHint=yes
ac_cv_have_x='have_x=yes	ac_x_includes='\'''\''	ac_x_libraries='\'''\'''
ac_cv_header_GL_gl_h=yes
ac_cv_header_GL_glu_h=yes
ac_cv_lib_GL___glEnd=no
ac_cv_objext=o
ac_cv_prog_CPP='gcc -E'
ac_cv_prog_HAVE_LIBPNG_CONFIG=yes
ac_cv_prog_ac_ct_CC=gcc
ac_cv_prog_cc_c89=
ac_cv_prog_cc_g=yes

## ----------------- ##
## Output variables. ##
## ----------------- ##

CC='gcc'
CFLAGS='-g -O2'
CPP='gcc -E'
CPPFLAGS=' -DHAVE_PNG_H -I/usr/include/libpng16'
DEFS='-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DHAVE_GL_GL_H=1 -DHAVE_GL_GLU_H=1'
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
EXEEXT=''
GREP=''
HAVE_FREETYPE_CONFIG=''
HAVE_LIBPNG_CONFIG='yes'
HAVE_PKG_CONFIG=''
HIDE_IF_NO_OPENGL='#'
LDFLAGS=''
LIBOBJS=''
LIBS=' -lpng16 -lX11'
LTLIBOBJS=''
NULL_CPPFLAGS=' -DHAVE_PNG_H -I/usr/include/libpng16 -DRGL_NO_OPENGL'
NULL_LIBS=' -lpng16'
OBJEXT='o'
PACKAGE_BUGREPORT=''
PACKAGE_NAME=''
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_URL=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
RGL_NO_OPENGL='TRUE'
SHELL='/bin/bash'
XMKMF=''
ac_ct_CC='gcc'
bindir='${exec_prefix}/bin'
build_alias=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE}'
dvidir='${docdir}'
exec_prefix='${prefix}'
host_alias=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/usr/local'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define HAVE_GL_GL_H 1
#define HAVE_GL_GLU_H 1

configure: exit 0

Thank you so much for your time I will appreciate any help!

  • rgl Version: 0.107.14
  • R Version: 4.0.2
  • Platform: Linux csaybar-pc01 5.8.0-63-generic -Ubuntu SMP Tue Jul 13 15:59:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

csaybar avatar Sep 11 '21 08:09 csaybar

Where is the GL lib located on your system? The configure script is not finding it. You can use the --with-gl-libs=DIR configure option to override the automatic detection.

dmurdoch avatar Sep 11 '21 09:09 dmurdoch

Hi @dmurdoch thanks for your reply,

I got the same error after running:

R CMD INSTALL --configure-args="--with-gl-libs=/usr/include/GL/"
csaybar@csaybar-pc01:~$ Tree /usr/include/GL
/usr/include/GL
├── freeglut_ext.h
├── freeglut.h
├── freeglut_std.h
├── glcorearb.h
├── glext.h
├── gl.h
├── glu.h
├── glu_mangle.h
├── glut.h
├── glxext.h
├── glx.h
├── glxint.h
├── glxmd.h
├── glxproto.h
├── glxtokens.h
└── internal
    ├── dri_interface.h
    └── glcore.h
csaybar@csaybar-pc01:~$ glxinfo | grep 'version'
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
OpenGL core profile version string: 4.6.0 NVIDIA 460.73.01
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL version string: 4.6.0 NVIDIA 460.73.01
OpenGL shading language version string: 4.60 NVIDIA
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 460.73.01
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
    GL_EXT_shader_group_vote, GL_EXT_shader_implicit_conversions, 

csaybar avatar Sep 11 '21 10:09 csaybar

Those are the header files. The lib is probably named something like libGL.so. It would normally be in a subdir of /usr, maybe /usr/lib or /usr/local/lib.

dmurdoch avatar Sep 11 '21 10:09 dmurdoch

Thank you so much for your help. It seems that the libGL.so file was stored in my NVIDIA folder by default.

find / -name 'libGL.so'
/usr/lib/nsight-systems/host-linux-x64/Mesa/libGL.so

However, after running the install process again appears a different error.

install.packages("rgl", configure.args = "--with-gl-libs=/usr/lib/nsight-systems/host-linux-x64/Mesa/")

** testing if installed package can be loaded from temporary location
Error in dyn.load(dynlib <- getDynlib(dir)) : 
  unable to load shared object '/home/csaybar/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-rgl/00new/rgl/libs/rgl.so':
  libGL.so: cannot open shared object file: No such file or directory
Warning: 	Loading rgl's DLL failed. 
Warning: Trying without OpenGL...
ERROR: loading failed
* removing ‘/home/csaybar/R/x86_64-pc-linux-gnu-library/4.0/rgl’
* restoring previous ‘/home/csaybar/R/x86_64-pc-linux-gnu-library/4.0/rgl’
Warning in install.packages :
  installation of package ‘rgl’ had non-zero exit status

I tried to store the path in my PATH ENV but it doesn't work:

Sys.setenv(PATH=paste("/usr/lib/nsight-systems/host-linux-x64/Mesa/", Sys.getenv("PATH"), sep=":"))
install.packages("rgl")

csaybar avatar Sep 11 '21 11:09 csaybar

I'm afraid you're going to need help from someone who knows Ubuntu better than me.

In the meantime, you should be able to build with the configure option "--disable-opengl". This will stop rgl from being able to display in an X11 window, but you should still be able to run rglwidget() to get a display in a browser.

dmurdoch avatar Sep 11 '21 12:09 dmurdoch

I'm closing this as there doesn't seem to be anything I can do.

dmurdoch avatar Mar 11 '23 17:03 dmurdoch