i was just going through some source code and came across the directive

#pragma comment( lib, "irrlicht.lib" );

I got mixed and confusing answers when i read about it in the vc++ documentation. Could someone please explain clearly the purpose or necessity for such code? I do have a hunch it has something to do with linking !!

>Could someone please explain clearly the purpose or necessity for such code?
If you're using code from an external library, you usually have to link a special .lib file. Usually how it's done in most IDEs is there's special configuration options, which allow you to specify the .libs to link with.

The #pragma is a compiler-specific feature to allow you to link the libs without going into the linker config.

Ah, now i get it. instead of that statement, i added the .lib file in the linker input options of the solution in vc++ express and commented the statement. It built and ran normally.

Now what you said would suffice for lib files. How do i link a dll file? is there a directive to link a dll file using compiler specific feature or is it a setting in the IDE. And would it be possible to elaborate the difference between a lib file and dll (.so in linux ).

i already vaguely understand! but im confused about which calls which. does the dll call lib files or lib calls dll files. Or do neither call each other, but for the source code... which calls either one or both.

>Now what you said would suffice for lib files. How do i link a dll file?
DLL stands for Dynamic Link Library. So they aren't linked at compile time, they are dynamically linked when you run the program.

Usually how it tends to work is that a library will come with 2 parts: .lib and .dll. You add the .lib to the linker options, and the operating system takes care of the rest. Of course, there are other situations where the entire library is statically linked, in which case no DLL is necessary (just the .lib). But I have never used statically-linking libraries in the Windows environment, so I may not be entirely correct.

>
Usually how it tends to work is that a library will come with 2 parts: .lib and .dll. You add the .lib to the linker options, and the operating system takes care of the rest.

how does the OS know that the dll can be found in a particular place, may i ask?. In the IDE settings I explicitly set the extra include directories and extra lib directories. But i see no provision for extra dll directories. so how does the OS know where to search for the dll file it requires ?

how does the OS know that the dll can be found in a particular place, may i ask?. In the IDE settings I explicitly set the extra include directories and extra lib directories. But i see no provision for extra dll directories. so how does the OS know where to search for the dll file it requires ?

I'm not entirely sure of the technical details, but there are some default directories where the system's DLLs are located. Windows checks these when looking for the DLL. The OS also checks in the directory that the executable is located in.

The fact that the OS checks in the directory of the .exe is the only thing im sure off. cos up until now, thats the only way i solve the "xxxxx.exe cannot run cos xxxxxx.dll could not be found" dialogs when they pop up.

thanks for clearing some of my doubts mate. I know, that I know more about lib and dll files than 5 posts ago ;-). albeit i also know there is truck loads to learn yet.

It's probably best to leave the Irrlicht dll file in the directory that your application resides in. I couldn't find any information on Irrlicht's web page on where to install the dll, and I haven't used Windows recently enough to remember the directory where all of them are stored.

And I wouldn't worry about it too much, having dlls with your program's executable is fine.

Ah, that answers a few questions. Thanks for the link mate. that cleared a few more doubts !

This question has already been answered. Start a new discussion instead.