How to get augmented reality: examples of practical guidance?

I recently bought a book: Augmented Reality: A Practical Guide . He has some sample code that he says works on Windows, macOS and Linux.

But I cannot run binaries. Does anyone have this book and binaries to run on Ubuntu?

I also cannot figure out how to compile the examples in Ubuntu. How should I do it?

Here's what he says:

Compilation for Linux

Refreshingly, no changes are required to get the programs in this chapter to compile for Linux, but as with Windows, you will first have to find the GL and GLUT files. This may mean that you will need to download the correct GLUT version for your device.

You need to link in the GL, GLU and GLUT libraries and provide the path to the GLUT header file and the files it includes. See if there is a glut.h file in the directory /usr/include/GL

; otherwise elsewhere - you can use the command find / -name "glut.h"

to search the entire machine, or you can use the locate ( locate glut.h

) command .

You may need to customize the paths, but here's an example compile command:

$ gcc -o opengl_template opengl_template.cpp -I /usr/include/GL -I \

     /usr/include -lGL -lGLU -lglut

gcc is a C / C ++ compiler that must be present on your Linux or Unix machine. The command line argument -I /usr/include/GL

tells gcc to look in /usr/include/GL

for included files. In this case, you will find glut.h and what it includes. When linking in libraries with gcc, you use a switch -lX

where X is the name of your library and there is the corresponding file libX.a

somewhere in your path. For this example, you want to link library files libGL.a

, libGLU.a

and libglut.a

so you will be using gcc arguments -lGL -lGLU -lglut

. These three files are in the default directory /usr/lib/

, so you don't need to specify their location as you did with glut.h. If you did, you need to specify the path to the library, you must add -L to the path.

To run the compiled program, type ./opengl_template

or, if the current directory is in your shell paths, just opengl_template

.

When working on Linux, it is important to know that you may need to keep your texture files no larger than 256 by 256 pixels, or look for settings on your system to raise this limit. Often an OpenGL program will run on Windows, but will produce an empty white texture on Linux as long as the texture is reduced in size.

The above instructions don't make any sense to me. Should I use gcc to compile or use Eclipse?

If I am using Eclipse or gcc, what do I need to do to compile and run the program?

+2


source to share


1 answer


You can use eclipse if you like, but that doesn't matter.

Eclipse is just an IDE, that is, a beautiful GUI that knows how to interact with the compiler.

Command:

gcc -o opengl_template opengl_template.cpp -I /usr/include/GL -I /usr/include -lGL -lGLU -lglut

      



Should work from the command line. If you want, you can set up an eclipse project that will invoke the same command line when compiled. It looks like you are compiling a single CPP including GL headers and linking to GL, GLU and GLUT.

It should create an output executable named opengl_template

I haven't compiled it on Ubuntu, but it shouldn't be. You can ignore whatever it takes to find GL libraries. You should already have them.

Good luck!

0


source







All Articles