Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Why am I able to link opengl32.lib even if I don't have one?  (Read 2604 times)

0 Members and 1 Guest are viewing this topic.

yj1214

  • Newbie
  • *
  • Posts: 14
    • View Profile
Why am I able to link opengl32.lib even if I don't have one?
« on: April 07, 2015, 04:18:06 am »
Little bit confused about how MinGW linking works...


I have a test folder and inside of the test folder, I have a exe file and have a lib folder which contains bunch of SFML lib files. Now, here's where I pissed off. I created a makefile that will compile my main.cpp file and I used -L to specify to look for the lib folder and used -l flags to tell which libs i'm using. Since I'm only using window features, I used -llibsfml-window. I compiled my main.cpp and got an error...I changed my -llibsfml-window to -lsfml-window which doesn't make sense because in my lib folder, there is no such file called sfml-window, but it worked, and I have no idea how this is working...maby because i'm newb and don't really understand how MinGW works...for me, more confusing thing is that even though I have no file called opengl32 in my lib folder, it compiles fine...am I just not understanding how MinGW works? how come MinGW compiles opengl32.lib even though I don't have opengl32.lib? thanks.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Why am I able to link opengl32.lib even if I don't have one?
« Reply #1 on: April 07, 2015, 06:52:12 am »
The "-l" option specifies library names, not file names. The actual file is found based on the library name and file naming conventions on the specific platform you are compiling on. For example, on Linux "-lsfml-window" results in linking to a file named "libsfml-window.so", on other systems the files are named differently according to the naming conventions of the system, but the library name "sfml-window that you specify with "-l" stays the same.
As for the "opengl32" library, you do have it on your system. It's usually provided by your graphics card driver or the base operating system and is usually in one of the default library search locations that the compiler searches for libraries even without you specifying any locations to search with "-L".

Read more here: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
And here: https://gcc.gnu.org/onlinedocs/
« Last Edit: April 07, 2015, 07:49:00 am by Jesper Juhl »

 

anything