Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's #pragma comment (lib, "lib/glut32.lib")?

I saw the code on the top of a GLUT demo and I'm curious about its functionality.

Why would someone want to write a #pragma instead of just including the library?

like image 681
andandandand Avatar asked Mar 03 '26 15:03

andandandand


1 Answers

This pragma allows the library author to define library imports based on a range of criteria that can be analysed at compile-time. For instance, you can link against different libs, based on whether you want to link with:

  • multithreading on or off;
  • the shared or static version of the library in question;
  • the shared or static version of the standard runtime library;
  • the debug or release library;
  • the 32-bit or 64-bit library.

With the pragma form, all this can be decided via #ifdef preprocessor tests in one of the library's header files.

like image 177
Marcelo Cantos Avatar answered Mar 05 '26 04:03

Marcelo Cantos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!