-
March 4th, 2008, 07:16 PM
#1
#pragma comment
Hi all,
I am using the following code line:
Code:
#pragma comment(lib, "wininet.lib")
Is there a way to print a message to the user if the file not found??
For example: If I rename wininet.lib to something else, I get a Linker error when compiling the code.
Ideally I would the user to get a message like: "wininet.lib not found try reinstalling the program"
How can I do it??
Many thanks!!!
-
March 4th, 2008, 07:58 PM
#2
Re: #pragma comment
To my knowledge there aren't any pragmas or precompiler constructs that can check for missing files.
Maybe you can solve your problem with a buildscript and the FindUnderPath task.
- petter
-
March 5th, 2008, 09:30 AM
#3
Re: #pragma comment
If you mean at runtime, there will be no such thing.
Lib will be statically linked to your .exe file
What you should deal with is more when linking DLL (with LoadLibrary() for example)
Visual Studio 2005 Professional
-
March 6th, 2008, 05:26 AM
#4
Re: #pragma comment
Thank you guys.
Yes Runtime.
If I understand it correctly than when I compile my program ,
The EXE created already contain the LIB file???
So when I publish my program I don't need to add the lib file to the pakage installer, only the dll.
Is that right?
Thanks again
Last edited by Salvadoravi; March 6th, 2008 at 05:29 AM.
-
March 6th, 2008, 05:57 AM
#5
Re: #pragma comment
Originally Posted by Salvadoravi
Thank you guys.
Yes Runtime.
If I understand it correctly than when I compile my program ,
The EXE created already contain the LIB file???
So when I publish my program I don't need to add the lib file to the pakage installer, only the dll.
Is that right?
Thanks again
Depends whether you link the library statically or dynamically. When linking statically all executable code is taken from the library and copied into your application code (you don´t need additional DLLs, but it makes your application bigger).
When linking dynamically your application loads a DLL when needed and calls code from that library, but you need that DLL on every system to run your application.
- Guido
-
March 6th, 2008, 08:08 AM
#6
Re: #pragma comment
Thank you,
I am still a little bit confused about the *.lib file.
Is it needed on the client computer to run the program?
Or is it just needed by the compiler to create the exe??
Many thanks!
-
March 6th, 2008, 08:16 AM
#7
Re: #pragma comment
.lib files are never used by an executable (except for linkers ). You won´t have to package it with your executable, just make sure you either link statically or provide the DLL your application is linked against.
- Guido
-
March 6th, 2008, 08:20 AM
#8
Re: #pragma comment
I think that it's the DLL file that is needed, not the .lib file... I could be wrong. :s
Edit: Woohoo I was right... one question, how do find out if you are statically or dynamically linking to a library? For example.. I use SDL but I am unsure if I am statically linking to it or not? I ask because when I debug my program which uses the SDL library, there are HEAPS of lines saying this during the period that images are being loaded and it slows down my program:
Code:
'Checkers_SDL.exe': Loaded 'C:\WINDOWS\system32\zlib1.dll', No symbols loaded.
'Checkers_SDL.exe': Unloaded 'C:\WINDOWS\system32\libpng12.dll'
'Checkers_SDL.exe': Unloaded 'C:\WINDOWS\system32\zlib1.dll'
'Checkers_SDL.exe': Loaded 'C:\WINDOWS\system32\libpng12.dll', No symbols loaded.
'Checkers_SDL.exe': Loaded 'C:\WINDOWS\system32\zlib1.dll', No symbols loaded.
'Checkers_SDL.exe': Unloaded 'C:\WINDOWS\system32\libpng12.dll'
I'm presuming this is dynamic linking? I'd prefer to link statically because it's just too slow...
Sorry about the semi-thread-hi-jack.
Last edited by Mybowlcut; March 6th, 2008 at 08:25 AM.
-
March 6th, 2008, 08:27 AM
#9
Re: #pragma comment
Originally Posted by GNiewerth
.lib files are never used by an executable (except for linkers ). You won´t have to package it with your executable, just make sure you either link statically or provide the DLL your application is linked against.
Excellent, Thank you GNiewerth!
-
March 6th, 2008, 08:55 AM
#10
Re: #pragma comment
Originally Posted by Mybowlcut
I think that it's the DLL file that is needed, not the .lib file... I could be wrong. :s
Edit: Woohoo I was right... one question, how do find out if you are statically or dynamically linking to a library? For example.. I use SDL but I am unsure if I am statically linking to it or not? I ask because when I debug my program which uses the SDL library, there are HEAPS of lines saying this during the period that images are being loaded and it slows down my program:
Code:
'Checkers_SDL.exe': Loaded 'C:\WINDOWS\system32\zlib1.dll', No symbols loaded.
'Checkers_SDL.exe': Unloaded 'C:\WINDOWS\system32\libpng12.dll'
'Checkers_SDL.exe': Unloaded 'C:\WINDOWS\system32\zlib1.dll'
'Checkers_SDL.exe': Loaded 'C:\WINDOWS\system32\libpng12.dll', No symbols loaded.
'Checkers_SDL.exe': Loaded 'C:\WINDOWS\system32\zlib1.dll', No symbols loaded.
'Checkers_SDL.exe': Unloaded 'C:\WINDOWS\system32\libpng12.dll'
I'm presuming this is dynamic linking? I'd prefer to link statically because it's just too slow...
Sorry about the semi-thread-hi-jack.
This happens only in debug builds, I think. For the release build there should be no significant speed difference between dynamic and static linking.
There are tools like PeBrowsePro and DependencyWalker that inspect executables/DLLs and displays their import section/dependencies.
- Guido
-
March 6th, 2008, 09:43 AM
#11
Re: #pragma comment
Originally Posted by GNiewerth
This happens only in debug builds, I think. For the release build there should be no significant speed difference between dynamic and static linking.
There are tools like PeBrowsePro and DependencyWalker that inspect executables/DLLs and displays their import section/dependencies.
Yeah but that's just it, the wait for it just to get past this part takes atleast 10 seconds each time. Why would I need to search for import section/dependencies?
-
March 6th, 2008, 10:00 AM
#12
Re: #pragma comment
To check which DLLs are loaded at startup.
- Guido
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|