Building OpenGL on JTX1

I’m new to OpenGL, and am trying to build a basic Hello World program I found at this site: BadproG.com | Programming with C, C++, Java SE, Java EE, Android, UNIX and GNU/Linux, PHP, MySQL, Symfony, Zend and much more!

I tried to compile as recommended by typing “g++ main.cpp -o lookAtThis -lglut” where lookAtThis is the name of the application and also the name of the folder that contains main.cpp. I run this command while in lookAtThis/.

Every time I try to compile the .cpp file, I get the following error:

"
/usr/bin/ld: /tmp/ccuoaunx.o: undefined reference to symbol ‘glClear’
//usr/lib/arm-linux-gnueabihf/tegra/libGL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
"

Can anyone point me in the write direction to write and compile OpenGL programs from scratch on the JTX1?

Thank you very much!

What you’re seeing is that a library containing the required symbols from libGL has not been named. The example command line would only work if libglut.so provided everything. On my Fedora host this command is needed (this links in libGL.so symbols):

g++ main.cpp -o lookAtThis -lglut -lGL

Looks like I don’t actually have glut installed on my JTX1, so I have not tested this on Jetson (if all the packages are installed both Fedora and Jetson should be the same for that).

WOOHOO, it works! You’re a lifesaver linuxdev :)

Do you know how I can find the appropriate command to link in the right libraries when compiling? Is there a way to do this so that I don’t have to place in all the flags every time I want to compile? Is that what makefiles are for?

I’m a super-noob, thanks for your help!

Quite often knowing which library is either a case of a man page or a web site on the API. E.g., “man glClear”. Khronos group ([url]https://www.khronos.org/[/url]) is the keeper of many of the important graphics interfaces (OpenGL, OpenGLES, Vulkan, so on)…so keeping a link to Khronos handy will help for your case as well. If you’ve installed a docs package for something it’s usually in “/usr/share/doc”, so browse that.

Yes, makefiles are just a way to put that information in once, and “make” whatever named recipe/target you want (there will be a default recipe/target, plus you can add more, e.g., “make clean” to get rid of temp files…common targets also include a debug version of the program).