problems in compiling and running a graphics application

Hi!

I’m trying to compile (and then hopefully execute) this program.

First of all, I would point out that I didn’t write this code and that this belong to the legitimate author (you can find his name and contact in the README file of the project).

I’m working in a Ubuntu 16.04 (64 bit) environment, on a virtual machine.

This are the steps I did and where I stopped.

After uncompressed the archive, I moved in the directory crane-0.1 and ran this command

$ ./configure; make; make install

the configuration phase failed

...
checking GL/glut.h usability... no
checking GL/glut.h presence... no
checking for GL/glut.h... no
configure: error: Can't find glut.h,install libglut3-dev first!

so I installed the required packages and re-ran the installation command

$ sudo apt-get install freeglut3 freeglut3-dbg freeglut3-dev
...
$ ./configure; make; make install

this time the configure phase terminated correctly, but I got this error in the make phase

img #1

so I added the line

#include <unistd.h>

at the file src/ClawCrane.cpp and this solved the problem with the usleep function, but the make phase gave another problem

img #2

so I changed the line #167 in the src/Makefile from

crane_LDFLAGS = -lglut -lGLU -lGL --allow-multiple-definition

to

crane_LDFLAGS = -lglut -lGLU -lGL -z muldefs

this solved the last problem, so I ran the make phase again but I got others errors

img #3

This is the point where I now stopped. I see that something is wrong with dependency of some library, but i don’t know well how to move from here.

Thank you for reading and for any help!

Interesting. I had plans to set up a Linux system and devote a section of my YouTube channel on OpenGL, just to that.

Anyways, aside from my lack of Linux experience… It looks like you have a linker issue, either that or an include issue. Are you sure you are including all the necessary .H files? Also, check if you are linking all the necessary .LIB files.

As a side note, my YouTube channel is here, and recently I re-made a ‘getting started with opengl and it’s third party libraries’, as it was the most popular video in my collection:

https://www.youtube.com/channel/UCzx8alrxVELz5h1dfCdkdfg?view_as=subscriber

Cheers,

Jeff

Thanks for the answer!

Yes I understood that this is the problem, but unfortunately I don’t know which other library to include. So I hope that someone that have already experience with graphics programming in linux environment can help me to risolve the issue!

[QUOTE=ArcticPi;1290726]…this solved the last problem, so I ran the make phase again but I got others errors


g++ -O3 -Wall -Werror -lglut -lGLU -lGL ... -o crane stuff1.o stuff2.o ...

unresolved reference to 'glut...'
unresolved reference to 'glu...'
unresolved reference to 'gl...'

This is the point where I now stopped. I see that something is wrong with dependency of some library, but i don’t know well how to move from here.[/QUOTE]

Try moving the library list ("-lglut -lGLU -lGL") to the end of the command. You want them to resolve the dependencies in your .o’s.

Also, I’d remove the “-z muldefs” unless you know exactly why it is you need it and have established that there’s no better way to resolve this.

Thank you so much! I followed your tips and I finally managed to compile the application! :o

This is exactly what I did.

  • file crane-0.1/src/Makefile

    I removed the flag “-z muldefs” from the line #167

    then I changed lines #53 and #54 to move the flags “-lglut -lGLU -lGL” at the end of the link command


    crane_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ $(LDFLAGS) -o $@ $(crane_LDFLAGS)


  • file crane-0.1/test/Makefile

    I modified the following lines to move the flags “-lglut -lGLU -lGL” at the end of each link command


    #242 $(ControllerTest_LINK) $(ControllerTest_OBJECTS) $(ControllerTest_LDADD) $(LIBS) $(ControllerTest_LDFLAGS) #245 $(PhysicalBallTest_LDADD) $(LIBS) $(PhysicalBallTest_LDFLAGS) #248 $(VecTest_LINK) $(VecTest_OBJECTS) $(VecTest_LDADD) $(LIBS) $(VecTest_LDFLAGS)

Now I can run the application

IMG #1

but it crashes miserably after few seconds of execution

IMG #2

This is the complete output of the application after the fault.

*** buffer overflow detected ***: crane terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f8c8b6c17e5]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f8c8b76315c]
/lib/x86_64-linux-gnu/libc.so.6(+0x117160)[0x7f8c8b761160]
/lib/x86_64-linux-gnu/libc.so.6(+0x1166c9)[0x7f8c8b7606c9]
/lib/x86_64-linux-gnu/libc.so.6(_IO_default_xsputn+0x80)[0x7f8c8b6c56b0]
/lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0x7bd)[0x7f8c8b69792d]
/lib/x86_64-linux-gnu/libc.so.6(__vsprintf_chk+0x84)[0x7f8c8b760754]
/lib/x86_64-linux-gnu/libc.so.6(__sprintf_chk+0x7d)[0x7f8c8b7606ad]
crane[0x402d3c]
/usr/lib/x86_64-linux-gnu/libglut.so.3(glutMainLoopEvent+0x184)[0x7f8c8c7b7894]
/usr/lib/x86_64-linux-gnu/libglut.so.3(glutMainLoop+0xa5)[0x7f8c8c7b8145]
crane[0x4028c0]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f8c8b66a830]
crane[0x4029c9]
======= Memory map: ========
00400000-00409000 r-xp 00000000 08:01 134473                             /usr/local/bin/crane
00608000-00609000 r--p 00008000 08:01 134473                             /usr/local/bin/crane
00609000-0060a000 rw-p 00009000 08:01 134473                             /usr/local/bin/crane
02473000-02d31000 rw-p 00000000 00:00 0                                  [heap]
7f8c82240000-7f8c82c40000 rwxp 00000000 00:00 0 
7f8c82c40000-7f8c82d01000 rw-p 00000000 00:00 0 
7f8c82dc0000-7f8c82ebb000 rw-p 00000000 00:00 0 
7f8c82ebb000-7f8c82ef2000 r-xp 00000000 08:01 273707                     /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7f8c82ef2000-7f8c830f1000 ---p 00037000 08:01 273707                     /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7f8c830f1000-7f8c830f2000 r--p 00036000 08:01 273707                     /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7f8c830f2000-7f8c830f3000 rw-p 00037000 08:01 273707                     /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7f8c830f3000-7f8c83106000 r-xp 00000000 08:01 6220                       /lib/x86_64-linux-gnu/libbsd.so.0.8.2
7f8c83106000-7f8c83305000 ---p 00013000 08:01 6220                       /lib/x86_64-linux-gnu/libbsd.so.0.8.2
7f8c83305000-7f8c83306000 r--p 00012000 08:01 6220                       /lib/x86_64-linux-gnu/libbsd.so.0.8.2
7f8c83306000-7f8c83307000 rw-p 00013000 08:01 6220                       /lib/x86_64-linux-gnu/libbsd.so.0.8.2
7f8c83307000-7f8c83308000 rw-p 00000000 00:00 0 
7f8c83308000-7f8c8332d000 r-xp 00000000 08:01 6396                       /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f8c8332d000-7f8c8352c000 ---p 00025000 08:01 6396                       /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f8c8352c000-7f8c83530000 r--p 00024000 08:01 6396                       /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f8c83530000-7f8c83531000 rw-p 00028000 08:01 6396                       /lib/x86_64-linux-gnu/libtinfo.so.5.9
7f8c83531000-7f8c83562000 r-xp 00000000 08:01 272830                     /usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
7f8c83562000-7f8c83762000 ---p 00031000 08:01 272830                     /usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
7f8c83762000-7f8c83764000 r--p 00031000 08:01 272830                     /usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
7f8c83764000-7f8c83765000 rw-p 00033000 08:01 272830                     /usr/lib/x86_64-linux-gnu/libedit.so.2.0.53
7f8c83765000-7f8c83769000 rw-p 00000000 00:00 0 
7f8c83769000-7f8c83770000 r-xp 00000000 08:01 272878                     /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f8c83770000-7f8c8396f000 ---p 00007000 08:01 272878                     /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f8c8396f000-7f8c83970000 r--p 00006000 08:01 272878                     /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f8c83970000-7f8c83971000 rw-p 00007000 08:01 272878                     /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f8c83971000-7f8c86b18000 r-xp 00000000 08:01 268041                     /usr/lib/x86_64-linux-gnu/libLLVM-5.0.so.1
7f8c86b18000-7f8c86e68000 r--p 031a6000 08:01 268041                     /usr/lib/x86_64-linux-gnu/libLLVM-5.0.so.1
7f8c86e68000-7f8c86ed8000 rw-p 034f6000 08:01 268041                     /usr/lib/x86_64-linux-gnu/libLLVM-5.0.so.1
7f8c86ed8000-7f8c86f2b000 rw-p 00000000 00:00 0 
7f8c86f2b000-7f8c86f42000 r-xp 00000000 08:01 272835                     /usr/lib/x86_64-linux-gnu/libelf-0.165.so
7f8c86f42000-7f8c87141000 ---p 00017000 08:01 272835                     /usr/lib/x86_64-linux-gnu/libelf-0.165.so
7f8c87141000-7f8c87142000 r--p 00016000 08:01 272835                     /usr/lib/x86_64-linux-gnu/libelf-0.165.so
7f8c87142000-7f8c87143000 rw-p 00017000 08:01 272835                     /usr/lib/x86_64-linux-gnu/libelf-0.165.so
7f8c87143000-7f8c8714b000 r-xp 00000000 08:01 263597                     /usr/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0
7f8c8714b000-7f8c8734b000 ---p 00008000 08:01 263597                     /usr/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0
7f8c8734b000-7f8c8734c000 r--p 00008000 08:01 263597                     /usr/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0
7f8c8734c000-7f8c8734d000 rw-p 00009000 08:01 263597                     /usr/lib/x86_64-linux-gnu/libdrm_amdgpu.so.1.0.0
7f8c8734d000-7f8c87358000 r-xp 00000000 08:01 272804                     /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1.0.1
7f8c87358000-7f8c87557000 ---p 0000b000 08:01 272804                     /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1.0.1
7f8c87557000-7f8c87558000 r--p 0000a000 08:01 272804                     /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1.0.1
7f8c87558000-7f8c87559000 rw-p 0000b000 08:01 272804                     /usr/lib/x86_64-linux-gnu/libdrm_radeon.so.1.0.1
7f8c87559000-7f8c87560000 r-xp 00000000 08:01 271924                     /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
7f8c87560000-7f8c8775f000 ---p 00007000 08:01 271924                     /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
7f8c8775f000-7f8c87760000 r--p 00006000 08:01 271924                     /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
7f8c87760000-7f8c87761000 rw-p 00007000 08:01 271924                     /usr/lib/x86_64-linux-gnu/libdrm_nouveau.so.2.0.0
7f8c87761000-7f8c8776f000 r-xp 00000000 08:01 273595                     /usr/lib/x86_64-linux-gnu/libsensors.so.4.4.0
7f8c8776f000-7f8c8796e000 ---p 0000e000 08:01 273595                     /usr/lib/x86_64-linux-gnu/libsensors.so.4.4.0
7f8c8796e000-7f8c8796f000 r--p 0000d000 08:01 273595                     /usr/lib/x86_64-linux-gnu/libsensors.so.4.4.0
7f8c8796f000-7f8c87970000 rw-p 0000e000 08:01 273595                     /usr/lib/x86_64-linux-gnu/libsensors.so.4.4.0
7f8c87970000-7f8c87989000 r-xp 00000000 08:01 6415                       /lib/x86_64-linux-gnu/libz.so.1.2.8
7f8c87989000-7f8c87b88000 ---p 00019000 08:01 6415                       /lib/x86_64-linux-gnu/libz.so.1.2.8
7f8c87b88000-7f8c87b89000 r--p 00018000 08:01 6415                       /lib/x86_64-linux-gnu/libz.so.1.2.8
7f8c87b89000-7f8c87b8a000 rw-p 00019000 08:01 6415                       /lib/x86_64-linux-gnu/libz.so.1.2.8
7f8c87b8a000-7f8c885b8000 r-xp 00000000 08:01 399252                     /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
7f8c885b8000-7f8c887b7000 ---p 00a2e000 08:01 399252                     /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
7f8c887b7000-7f8c887f8000 r--p 00a2d000 08:01 399252                     /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
7f8c887f8000-7f8c88801000 rw-p 00a6e000 08:01 399252                     /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
7f8c88801000-7f8c889f8000 rw-p 00000000 00:00 0 
7f8c889f8000-7f8c889fd000 r-xp 00000000 08:01 272499                     /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f8c889fd000-7f8c88bfc000 ---p 00005000 08:01 272499                     /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f8c88bfc000-7f8c88bfd000 r--p 00004000 08:01 272499                     /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f8c88bfd000-7f8c88bfe000 rw-p 00005000 08:01 272499                     /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f8c88bfe000-7f8c88c00000 r-xp 00000000 08:01 272488                     /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f8c88c00000-7f8c88e00000 ---p 00002000 08:01 272488                     /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f8c88e00000-7f8c88e01000 r--p 00002000 08:01 272488                     /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f8c88e01000-7f8c88e02000 rw-p 00003000 08:01 272488                     /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f8c88e02000-7f8c88e05000 r-xp 00000000 08:01 1653                       /lib/x86_64-linux-gnu/libdl-2.23.so
7f8c88e05000-7f8c89004000 ---p 00003000 08:01 1653                       /lib/x86_64-linux-gnu/libdl-2.23.so
7f8c89004000-7f8c89005000 r--p 00002000 08:01 1653                       /lib/x86_64-linux-gnu/libdl-2.23.so
7f8c89005000-7f8c89006000 rw-p 00003000 08:01 1653                       /lib/x86_64-linux-gnu/libdl-2.23.so
7f8c89006000-7f8c8901e000 r-xp 00000000 08:01 1650                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f8c8901e000-7f8c8921d000 ---p 00018000 08:01 1650                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f8c8921d000-7f8c8921e000 r--p 00017000 08:01 1650                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f8c8921e000-7f8c8921f000 rw-p 00018000 08:01 1650                       /lib/x86_64-linux-gnu/libpthread-2.23.so
7f8c8921f000-7f8c89223000 rw-p 00000000 00:00 0 
7f8c89223000-7f8c89233000 r-xp 00000000 08:01 263122                     /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7f8c89233000-7f8c89432000 ---p 00010000 08:01 263122                     /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7f8c89432000-7f8c89433000 r--p 0000f000 08:01 263122                     /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7f8c89433000-7f8c89434000 rw-p 00010000 08:01 263122                     /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7f8c89434000-7f8c89455000 r-xp 00000000 08:01 273906                     /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f8c89455000-7f8c89654000 ---p 00021000 08:01 273906                     /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f8c89654000-7f8c89655000 r--p 00020000 08:01 273906                     /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f8c89655000-7f8c89656000 rw-p 00021000 08:01 273906                     /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f8c89656000-7f8c8965a000 r-xp 00000000 08:01 273874                     /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0.0.0
7f8c8965a000-7f8c89859000 ---p 00004000 08:01 273874                     /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0.0.0
7f8c89859000-7f8c8985a000 r--p 00003000 08:01 273874                     /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0.0.0
7f8c8985a000-7f8c8985b000 rw-p 00004000 08:01 273874                     /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0.0.0
7f8c8985b000-7f8c89872000 r-xp 00000000 08:01 273878                     /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7f8c89872000-7f8c89a71000 ---p 00017000 08:01 273878                     /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7f8c89a71000-7f8c89a73000 r--p 00016000 08:01 273878                     /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7f8c89a73000-7f8c89a74000 rw-p 00018000 08:01 273878                     /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7f8c89a74000-7f8c89a75000 r-xp 00000000 08:01 272482                     /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7f8c89a75000-7f8c89c74000 ---p 00001000 08:01 272482                     /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7f8c89c74000-7f8c89c75000 r--p 00000000 08:01 272482                     /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7f8c89c75000-7f8c89c76000 rw-p 00001000 08:01 272482                     /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7f8c89c76000-7f8c89c7b000 r-xp 00000000 08:01 272503                     /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7f8c89c7b000-7f8c89e7a000 ---p 00005000 08:01 272503                     /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7f8c89e7a000-7f8c89e7b000 r--p 00004000 08:01 272503                     /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7f8c89e7b000-7f8c89e7c000 rw-p 00005000 08:01 272503                     /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7f8c89e7c000-7f8c89e7e000 r-xp 00000000 08:01 272497                     /usr/lib/x86_64-linux-gnu/libXdamage.so.1.1.0
7f8c89e7e000-7f8c8a07d000 ---p 00002000 08:01 272497                     /usr/lib/x86_64-linux-gnu/libXdamage.so.1.1.0
7f8c8a07d000-7f8c8a07e000 r--p 00001000 08:01 272497                     /usr/lib/x86_64-linux-gnu/libXdamage.so.1.1.0
7f8c8a07e000-7f8c8a07f000 rw-p 00002000 08:01 272497                     /usr/lib/x86_64-linux-gnu/libXdamage.so.1.1.0
7f8c8a07f000-7f8c8a090000 r-xp 00000000 08:01 272501                     /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f8c8a090000-7f8c8a28f000 ---p 00011000 08:01 272501                     /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f8c8a28f000-7f8c8a290000 r--p 00010000 08:01 272501                     /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f8c8a290000-7f8c8a291000 rw-p 00011000 08:01 272501                     /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f8c8a291000-7f8c8a2bc000 r-xp 00000000 08:01 322483                     /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7f8c8a2bc000-7f8c8a4bb000 ---p 0002b000 08:01 322483                     /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7f8c8a4bb000-7f8c8a4bf000 r--p 0002a000 08:01 322483                     /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7f8c8a4bf000-7f8c8a4c0000 rw-p 0002e000 08:01 322483                     /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7f8c8a4c0000-7f8c8a4c1000 rw-p 00000000 00:00 0 
7f8c8a4c1000-7f8c8a4c2000 r-xp 00000000 08:01 273918                     /usr/lib/x86_64-linux-gnu/libxshmfence.so.1.0.0
7f8c8a4c2000-7f8c8a6c2000 ---p 00001000 08:01 273918                     /usr/lib/x86_64-linux-gnu/libxshmfence.so.1.0.0
7f8c8a6c2000-7f8c8a6c3000 r--p 00001000 08:01 273918                     /usr/lib/x86_64-linux-gnu/libxshmfence.so.1.0.0Aborted (core dumped)

Thanks for your help!

Whenever you see this (“*** buffer overflow detected ***” and/or “__fortify_fail” on the crash stack), you know that you’ve written past the end of a buffer (either one on the stack or on the heap).

Notice your app “crane” on the stack frame just above _sprintf_chk. Here, you’ve called sprintf() from crane and caused it to overflow a buffer in doing the sprintf, triggering the crash. You should be using snprintf() instead to avoid this kind of buffer overflow bug.

Also note that you can compile your (crane’s) object files with “-g” and that will add debug information to your binaries. This information will be used in the stack backtrace to tell you in your call traces exactly which of your functions called sprintf() and thus triggered the crash (rather than just reporting “crane[<hex address>]”. Try it and see, before you fix your bug.