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

1 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.

Related articles

Successfully Running The Makefile On Your Ubuntu Machine (all 8) RSS
├─ THIS biggrin Tue 3rd Mar, 1:46pm, Oscar HC.
├─ reply 1 thumbup Tue 3rd Mar, 1:51pm, Archy N.
├─ reply 2 thumbup Tue 3rd Mar, 4:48pm, ANONYMOUS
├─ reply 3   Wed 4th Mar, 8:01pm, Edward A.
├─ reply 4   Sat 7th Mar, 10:40am, Xavier F.
├─ reply 5   Mon 9th Mar, 9:14am, Mohammad J.
├─ reply 6   Tue 17th Mar, 6:30pm, David C.
└─ reply 7   Sat 28th Mar, 11:02am, ANONYMOUS
This Page


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