pragma

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2007
Posts: 21
Reputation: desijays is an unknown quantity at this point 
Solved Threads: 1
desijays desijays is offline Offline
Newbie Poster

pragma

 
0
  #1
Apr 4th, 2007
i was just going through some source code and came across the directive

  1. #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 !!
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: pragma

 
0
  #2
Apr 4th, 2007
>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.
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 21
Reputation: desijays is an unknown quantity at this point 
Solved Threads: 1
desijays desijays is offline Offline
Newbie Poster

Re: pragma

 
0
  #3
Apr 4th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: pragma

 
0
  #4
Apr 5th, 2007
>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.
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 21
Reputation: desijays is an unknown quantity at this point 
Solved Threads: 1
desijays desijays is offline Offline
Newbie Poster

Re: pragma

 
0
  #5
Apr 5th, 2007
Originally Posted by joeprogrammer View Post
>
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 ?
Last edited by desijays; Apr 5th, 2007 at 12:35 am.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: pragma

 
0
  #6
Apr 5th, 2007
Originally Posted by desijays View Post
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.
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 21
Reputation: desijays is an unknown quantity at this point 
Solved Threads: 1
desijays desijays is offline Offline
Newbie Poster

Re: pragma

 
0
  #7
Apr 5th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: pragma

 
0
  #8
Apr 5th, 2007
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.
"Technological progress is like an axe in the hands of a pathological criminal."
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: pragma

 
0
  #9
Apr 5th, 2007
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 21
Reputation: desijays is an unknown quantity at this point 
Solved Threads: 1
desijays desijays is offline Offline
Newbie Poster

Re: pragma

 
0
  #10
Apr 5th, 2007
Ah, that answers a few questions. Thanks for the link mate. that cleared a few more doubts !
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC