Understanding Linker File Names in C++ on Ubuntu

0
3
Asked By CodeNinja42 On

I've been diving into OpenGL and using the command `g++ gl.cpp -o gl -lGL -lGLU -lglut` to compile my programs. It works great, but I'm confused about the library names. Some of them are in uppercase like `GL` and `GLU`, while others are in lowercase. I tried searching in `/usr/include/GL`, but I only found files in lowercase. Why are some of these library names capitalized when I can't find any matching files?

2 Answers

Answered By DevGuru99 On

You're on the right track by searching in `/usr/include`, but that's where the header files live, which declare the functions. For the actual libraries, you'll want to check out `/usr/lib`. As for the casing, it's just a quirk of naming. There's no strict rule—it's how each library has been established over time. Modern libraries generally use lower case, but OpenGL is from a different era, so it's a mixed bag. Unfortunately, there's no universal manual for library naming; you'll just get familiar with them as you go.

Answered By TechWizard77 On

It sounds like you're looking into the OpenGL libraries. If you list out the files in `/usr`, you'd see something like `libGL.so`, which actually points to the library you need. The reason for the difference in case is due to historical naming conventions. Most libraries tend to be lower case nowadays, but older libraries like OpenGL have mixed casing due to their age and the way they were originally named. You don't really need to worry about the case; just stick to how they're referenced when linking.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.