Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help3003


This forum is provided to promote discussion amongst students enrolled in Graphics and Animation (CITS3003).
 
Options:
RSS cloud
Jump to:

Successfully Running The Makefile On Your Ubuntu Machine

8 of 275 articles shown, currently no other people reading this forum.
photo
From: Oscar HC.
Date: Tue 3rd Mar, 1:46pm
Summary: biggrin
Actions: 
        Login-to-reply
Hey all,

Just spent a while troubleshooting the makefile to get it running on my laptop, running Ubuntu 18.04.

I thought I'd throw out some help to anyone else who wants to get the code working on their own Linux machine.

1. Follow the instructions given.
-------------------------------------------------

Download the labs-examples, unzip the file, navigate to the labs-example/CHAPTER02_CODE/LINUX_VERSIONS.

Let's try to make the files...

> $ make example1
> g++   -I../../include example1.cpp ../../Common/InitShader.o   /usr/lib64/libglut.so /usr/lib64/libGL.so.1 -lXmu /usr/lib64/libX11.so -lm -o example1
> g++: error: /usr/lib64/libglut.so: No such file or directory
> g++: error: /usr/lib64/libGL.so.1: No such file or directory
> g++: error: /usr/lib64/libX11.so: No such file or directory
> make: *** [Makefile:40: example1] Error 1

Hmm, need to install some stuff. I followed the instructions here: 

https://medium.com/        /how-to-install-a-opengl-environment-on-ubuntu-e3918cf5ab6c

2. Try again!
--------------------

> $ make example1
> g++   -I../../include example1.cpp ../../Common/InitShader.o   /usr/lib64/libglut.so /usr/lib64/libGL.so.1 -lXmu /usr/lib64/libX11.so -lm -o example1
> g++: error: /usr/lib64/libglut.so: No such file or directory
> g++: error: /usr/lib64/libGL.so.1: No such file or directory
> g++: error: /usr/lib64/libX11.so: No such file or directory
> make: *** [Makefile:40: example1] Error 1

Hmm, same error.

Let's look one step deeper, we definitely installed what was required.

> $ whereis libglut.so
> libglut: /usr/lib/x86_64-linux-gnu/libglut.a /usr/lib/x86_64-linux-gnu/libglut.so

Ah! It looks like our lib files were installed to a different location to where the makefile is looking. We can fix that.

> $ nano Makefile

Find the line:

LIB = /usr/lib64

Change it to:

LIB = /usr/lib/x86_64-linux-gnu/

This might be different on your machine! Match it to the directory you found when you ran $ whereis libglut.so

3. Try again, again!
-----------------------------

> $ make example1
> g++   -I../../include example1.cpp ../../Common/InitShader.o   /usr/lib/x86_64-linux-gnu//libglut.so /usr/lib/x86_64-linux-gnu//libGL.so.1 -lXmu /usr/lib/x86_64-linux-gnu//libX11.so -lm -o example1
> /usr/bin/ld: ../../Common/InitShader.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
> /usr/bin/ld: final link failed: nonrepresentable section on output
> collect2: error: ld returned 1 exit status
> make: *** [Makefile:42: example1] Error 1

Ok, different error message. That's progress!XXOPTS += -no-pie

This took me ages to figure out. I followed the article here.

https://stackoverflow.com/questions/46827433/g-compile-error-rodata-can-not-be-used-when-making-a-shared-object-recomp

It looks like it's trying to make a position independent executable and having trouble. We can bypass that by adding the -no-pie flag to the Makefile.

> $ nano Makefile

Above the line starting with CXXINCS =

Add a line of text;

CXXOPTS += -no-pie

This should fix it, fixed it for me. No error message.

Try one last time!
---------------------------

> $ ./example1


Looks good!

https://i.imgur.com/WClJzoM.png

Hopefully this helps someone out, saves someone some time.

Successfully Running The Makefile On Your Ubuntu Machine

photo
From: Archy N.
Date: Tue 3rd Mar, 1:51pm
Summary: thumbup
Actions: 
        Login-to-reply
i followed this and can confirm it works

Successfully Running The Makefile On Your Ubuntu Machine

photo
From: ANONYMOUS
Date: Tue 3rd Mar, 4:48pm
Summary: thumbup
Actions: 
        Login-to-reply
Thanks! This also worked for me using Ubuntu via Windows Subsystem for Linux (WSL). 

I got it working by following a few extra steps which I found here: 
https://github.com/microsoft/WSL/issues/2855#issuecomment-358861903

Successfully Running The Makefile On Your Ubuntu Machine

photo
From: Edward A.
Date: Wed 4th Mar, 8:01pm
Actions: 
        Login-to-reply
"Oscar Hermoso Clarke"                               wrote:

> Hey all,
> 
> Just spent a while troubleshooting the makefile to get it running on my laptop, running Ubuntu 18.04.
> 
> I thought I'd throw out some help to anyone else who wants to get the code working on their own Linux machine.
> 
> 1. Follow the instructions given.
> -------------------------------------------------
> 
> Download the labs-examples, unzip the file, navigate to the labs-example/CHAPTER02_CODE/LINUX_VERSIONS.
> 
> Let's try to make the files...
> 
> > $ make example1
> > g++   -I../../include example1.cpp ../../Common/InitShader.o   /usr/lib64/libglut.so /usr/lib64/libGL.so.1 -lXmu /usr/lib64/libX11.so -lm -o example1
> > g++: error: /usr/lib64/libglut.so: No such file or directory
> > g++: error: /usr/lib64/libGL.so.1: No such file or directory
> > g++: error: /usr/lib64/libX11.so: No such file or directory
> > make: *** [Makefile:40: example1] Error 1
> 
> Hmm, need to install some stuff. I followed the instructions here: 
> 
> https://medium.com/        /how-to-install-a-opengl-environment-on-ubuntu-e3918cf5ab6c
> 
> 2. Try again!
> --------------------
> 
> > $ make example1
> > g++   -I../../include example1.cpp ../../Common/InitShader.o   /usr/lib64/libglut.so /usr/lib64/libGL.so.1 -lXmu /usr/lib64/libX11.so -lm -o example1
> > g++: error: /usr/lib64/libglut.so: No such file or directory
> > g++: error: /usr/lib64/libGL.so.1: No such file or directory
> > g++: error: /usr/lib64/libX11.so: No such file or directory
> > make: *** [Makefile:40: example1] Error 1
> 
> Hmm, same error.
> 
> Let's look one step deeper, we definitely installed what was required.
> 
> > $ whereis libglut.so
> > libglut: /usr/lib/x86_64-linux-gnu/libglut.a /usr/lib/x86_64-linux-gnu/libglut.so
> 
> Ah! It looks like our lib files were installed to a different location to where the makefile is looking. We can fix that.
> 
> > $ nano Makefile
> 
> Find the line:
> 
> LIB = /usr/lib64
> 
> Change it to:
> 
> LIB = /usr/lib/x86_64-linux-gnu/
> 
> This might be different on your machine! Match it to the directory you found when you ran $ whereis libglut.so
> 
> 3. Try again, again!
> -----------------------------
> 
> > $ make example1
> > g++   -I../../include example1.cpp ../../Common/InitShader.o   /usr/lib/x86_64-linux-gnu//libglut.so /usr/lib/x86_64-linux-gnu//libGL.so.1 -lXmu /usr/lib/x86_64-linux-gnu//libX11.so -lm -o example1
> > /usr/bin/ld: ../../Common/InitShader.o: relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
> > /usr/bin/ld: final link failed: nonrepresentable section on output
> > collect2: error: ld returned 1 exit status
> > make: *** [Makefile:42: example1] Error 1
> 
> Ok, different error message. That's progress!XXOPTS += -no-pie
> 
> This took me ages to figure out. I followed the article here.
> 
> https://stackoverflow.com/questions/46827433/g-compile-error-rodata-can-not-be-used-when-making-a-shared-object-recomp
> 
> It looks like it's trying to make a position independent executable and having trouble. We can bypass that by adding the -no-pie flag to the Makefile.
> 
> > $ nano Makefile
> 
> Above the line starting with CXXINCS =
> 
> Add a line of text;
> 
> CXXOPTS += -no-pie
> 
> This should fix it, fixed it for me. No error message.
> 
> Try one last time!
> ---------------------------


Worked for me on 18.04. 

Legend thanks :)
> 
> > $ ./example1
> 
> 
> Looks good!
> 
> https://i.imgur.com/WClJzoM.png
> 
> Hopefully this helps someone out, saves someone some time.

Successfully Running The Makefile On Your Ubuntu Machine

photo
From: Xavier F.
Date: Sat 7th Mar, 10:40am
Actions: 
        Login-to-reply
This can also be achieved by uncommenting the first LDLIBS and commenting out the latter.

Successfully Running The Makefile On Your Ubuntu Machine

photo
From: Mohammad J.
Date: Mon 9th Mar, 9:14am
Actions: 
        Login-to-reply
Thank you for sharing the comprehensive guide!

Successfully Running The Makefile On Your Ubuntu Machine

photo
From: David C.
Date: Tue 17th Mar, 6:30pm
Actions: 
        Login-to-reply
Thanks so much! I really appreciate you taking the time to write this.
This worked on Ubuntu 18.04.4 LTS x86_64 

Successfully Running The Makefile On Your Ubuntu Machine

photo
From: ANONYMOUS
Date: Sat 28th Mar, 11:02am
Actions: 
        Login-to-reply
thank you!
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020