Closed 130s closed 2 days ago
glut
is missing on my platform.
$ make
g++ -g -DGL_GLEXT_PROTOTYPES -I./glm-0.9.7.1 -I./include/ -I/usr/X11R6/include -I/sw/include -I/usr/sww/include -I/usr/sww/pkg/Mesa/include -c mytest3.cpp
g++ -g -DGL_GLEXT_PROTOTYPES -I./glm-0.9.7.1 -I./include/ -I/usr/X11R6/include -I/sw/include -I/usr/sww/include -I/usr/sww/pkg/Mesa/include -c shaders.cpp
g++ -g -DGL_GLEXT_PROTOTYPES -o mytest3 shaders.o mytest3.o -I./glm-0.9.7.1 -I./include/ -I/usr/X11R6/include -I/sw/include -I/usr/sww/include -I/usr/sww/pkg/Mesa/include -L./lib/nix -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
/usr/bin/ld: cannot find -lglut: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:18: mytest3] Error 1
I might want to keep the host environment so may do this on Docker.
Building instruction/FAQ
If you are using a synaptic-based distribution, like Ubuntu, run:
sudo apt-get install freeglut3-dev glew-utils libglew1.6-dev libfreeimage-dev
Don't want to corrupt the host too much so going for Docker. https://qiita.com/asuka1975/items/5384ff4c20accb87cdca is helpful.
On host
export PATH_LOCAL_WS=/home/noodler/link/ROS/130s/prooving_grounds/mooc/edx.org_CSE167x-UCSD_ComputerGraphics
export SRC_DOCKERIMG=nvidia/opengl:1.0-glvnd-devel-ubuntu22.04
export RESULT_DOCKERIMG=d130s/mooc:edx.org_CSE167x-UCSD_ComputerGraphics
docker run --network host \
-v $PATH_LOCAL_WS:/cws/src \
-v /dev:/dev \
-it $DOCKERIMG bash
docker run -it --rm \
--gpus all \
--hostname=gltest \
--volume $PATH_LOCAL_WS:/cws/src \
-e DISPLAY=$DISPLAY \
-e NVIDIA_DRIVER_CAPABILITIES=all \
-v /tmp/.X11-unix:/tmp/.X11-unix \
$SRC_DOCKERIMG
Then in container,
# apt update && apt-get install -y build-essential \
freeglut3-dev \
glew-utils \
libglew1.6-dev \
libfreeimage-dev
This won't become my Colcon/ROS2 project and also it'll be better to eliminate external dependencies so just following basic path without relying on Colcon, rosdep etc.
libglew1.6-dev
doesn't seem to be found. But a newer version is already installed. Maybe nvidia's Docker image already installs it?
# apt-get install -y libglew2.2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libglew2.2 is already the newest version (2.2.0-4).
libglew2.2 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 72 not upgraded.
# cd /cws/src/hw0-linux_osx
# make
g++ -g -DGL_GLEXT_PROTOTYPES -o mytest3 shaders.o mytest3.o -I./glm-0.9.7.1 -I./include/ -I/usr/X11R6/include -I/sw/include -I/usr/sww/include -I/usr/sww/pkg/Mesa/include -L./lib/nix -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
/usr/bin/ld: ./lib/nix/libGLEW.a(glew.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make: *** [Makefile:18: mytest3] Error 1
If your source files compile, but you have link errors, such as
/usr/bin/ld: final link failed: Nonrepresentable section on output
, it is likely our libraries, provided for convenience, are outdated, and don't work with your modern Linux distribution. Try removing the-L./lib/nix
in the Makefile (and possibly the-I./include
although this is not required). This will ensure the code simply uses the system libraries. If successful, you will need to make this change for all homeworks in the course.
So omitted the included lib files.
#INCFLAGS = -I./glm-0.9.7.1 -I./include/ -I/usr/X11R6/include -I/sw/include \
INCFLAGS = -I./glm-0.9.7.1 -I/usr/X11R6/include -I/sw/include \
-I/usr/sww/include -I/usr/sww/pkg/Mesa/include
#LDFLAGS = -L./lib/nix -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib \
LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib \
-L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
A lot of lines mention grew
so I suspect it missing. However I'm told before even running very first make
:
# apt-get install -y libglew2.2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libglew2.2 is already the newest version (2.2.0-4).
0 upgraded, 0 newly installed, 0 to remove and 71 not upgraded.
libglew-dev
is available on Ubuntu 22.04, which shows the same version 2.2.0-4 as the one above so this may not matter.
So I'm not yet sure where the error is arising from. I guess it's the linker who's shedding errors as I see errors only occurring with /usr/bin/ld
AFAICT.
To continue narrowing down, I removed the libs I installed and reverted makefile
content.
apt purge libfreeimage-dev libglew2.2-dev && apt autoremove
INCFLAGS = -I./glm-0.9.7.1 -I./include/ -I/usr/X11R6/include -I/sw/include \
#INCFLAGS = -I./glm-0.9.7.1 -I/usr/X11R6/include -I/sw/include \
-I/usr/sww/include -I/usr/sww/pkg/Mesa/include
LDFLAGS = -L./lib/nix -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib \
#LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib \
-L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
This indicates either:
ld
was able to reference libs in both (system / included in the h/w distribution) but have issues with the libs on each.ld
has never been able to ref the libs.Well at least I can say the 2nd line is also commented out when the 1st line is commented.
INCFLAGS = -I./glm-0.9.7.1 -I./include/ -I/usr/X11R6/include -I/sw/include \
#INCFLAGS = -I./glm-0.9.7.1 -I/usr/X11R6/include -I/sw/include \
-I/usr/sww/include -I/usr/sww/pkg/Mesa/include
LDFLAGS = -L./lib/nix -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib \
#LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib \
-L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
I confirmed that by removing the commented line then the output became different, which is the one at the bottom of https://github.com/kinu-garage/hut_10sqft/issues/1052#issuecomment-2199319735 that complains something about the included libs incompatibility.
/usr/bin/ld: ./lib/nix/libGLEW.a(glew.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: failed to set dynamic section sizes: bad value
Now different, more classic error.
#INCFLAGS = -I./glm-0.9.7.1 -I./include/ -I/usr/X11R6/include -I/sw/include \
-I/usr/sww/include -I/usr/sww/pkg/Mesa/include
INCFLAGS = -I./glm-0.9.7.1 -I/usr/X11R6/include -I/sw/include -I/usr/sww/include -I/usr/sww/pkg/Mesa/include
#LDFLAGS = -L./lib/nix -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib \
-L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
LDFLAGS = -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
# apt-get install -y libglew2.2 libfreeimage-dev
# make
g++ -g -DGL_GLEXT_PROTOTYPES -o mytest3 shaders.o mytest3.o -I./glm-0.9.7.1 -I/usr/X11R6/include -I/sw/include -I/usr/sww/include -I/usr/sww/pkg/Mesa/include -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
/usr/bin/ld: cannot find -lGLEW: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:22: mytest3] Error 1
I guess make
ended w/o errors. I think libglew2.2
is not supposed to be installed manually (install libglew-dev
instead)?
# apt purge -y libglew2.2 && apt-get install -y libglew-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libglew2.2
Suggested packages:
glew-utils
The following NEW packages will be installed:
libglew-dev libglew2.2
0 upgraded, 2 newly installed, 0 to remove and 71 not upgraded.
Need to get 483 kB of archives.
After this operation, 3641 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libglew2.2 amd64 2.2.0-4 [196 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libglew-dev amd64 2.2.0-4 [287 kB]
Fetched 483 kB in 2s (253 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libglew2.2:amd64.
(Reading database ... 37572 files and directories currently installed.)
Preparing to unpack .../libglew2.2_2.2.0-4_amd64.deb ...
Unpacking libglew2.2:amd64 (2.2.0-4) ...
Selecting previously unselected package libglew-dev:amd64.
Preparing to unpack .../libglew-dev_2.2.0-4_amd64.deb ...
Unpacking libglew-dev:amd64 (2.2.0-4) ...
Setting up libglew2.2:amd64 (2.2.0-4) ...
Setting up libglew-dev:amd64 (2.2.0-4) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
root@gltest:/cws/src/hw0-linux_osx# find /usr -iname *glew*
/usr/lib/x86_64-linux-gnu/pkgconfig/glew.pc
/usr/lib/x86_64-linux-gnu/libGLEW.so.2.2.0
/usr/lib/x86_64-linux-gnu/libGLEW.a
/usr/lib/x86_64-linux-gnu/libGLEW.so.2.2
/usr/lib/x86_64-linux-gnu/libGLEW.so
/usr/include/GL/glew.h
/usr/include/GL/wglew.h
/usr/share/doc/libglew2.2
/usr/share/doc/libglew-dev
root@gltest:/cws/src/hw0-linux_osx# make
g++ -g -DGL_GLEXT_PROTOTYPES -o mytest3 shaders.o mytest3.o -I./glm-0.9.7.1 -I/usr/X11R6/include -I/sw/include -I/usr/sww/include -I/usr/sww/pkg/Mesa/include -L/usr/X11R6/lib -L/sw/lib -L/usr/sww/lib -L/usr/sww/bin -L/usr/sww/pkg/Mesa/lib -lGLEW -lglut -lGLU -lGL -lX11 -lfreeimage
root@gltest:/cws/src/hw0-linux_osx#
H/W0 submitted but ran into tech issue, requested support.
Cont'd from https://github.com/kinu-garage/hut_10sqft/issues/1010#issuecomment-2199204246 toward a bigger goal https://github.com/kinu-garage/essay_in_idleness/issues/150