Discussion:
Why is #pragma comment(lib, "atlthunk.lib") needed in source file?
(too old to reply)
TFS
2010-08-26 08:48:03 UTC
Permalink
I'm trying to use VC++ 2008 Express (in 32bit XP). I'm told to install WDK
7.1.0 in order to get ATL. After installing WDK and making the "build -cZ",
I added all the necessary folder paths for "Include" and "Library" in VC++
2008 Express. More exactly, I went to Tools menu > Options , then in
"Projects and Solutions" branch > "VC++ Directories" sub-branch, I added the
following paths to Include:
* C:\WinDDK\7600.16385.1\inc\atl71
* C:\WinDDK\7600.16385.1\inc\api
* C:\WinDDK\7600.16385.1\inc\mfc42
and the following to Library:
* C:\WinDDK\7600.16385.1\lib\ATL\i386

So far so good, right? Then comes the strange thing that I don't understand.

For some projects which were written in VC++ 2003, 2005 or 2008 (not
express), sometimes I have to add
#pragma comment(lib, "atlthunk.lib")
in source code file, eg in stdafx.h

I understand that this instruction tells the linker to look for atlthunk.lib
file. But why just this file in particular? You see,
C:\WinDDK\7600.16385.1\lib\ATL\i386 contains four lib files:

atl.lib, atls.lib, atlsd.lib and atlthunk.lib.

The other three lib files are loaded correctly without I need to write
something like
#pragma comment(lib, "atl.lib")

Then why does this atlthunk.lib require us to change source code? Is there
any side-effect is the project is opened in VC++ 2008 full edition again?
_______

Technical detail in case you ask why atlthunk.lib is needed:
When atlwin.h or atlcom.h is included and a certain memroy allocation
function is called, this atlthunk.lib is needed.
Maxim S. Shatskih
2010-08-26 23:20:38 UTC
Permalink
WDK contains some ATL in it, no need to include it from VC++
--
Maxim S. Shatskih
Windows DDK MVP
***@storagecraft.com
http://www.storagecraft.com
Post by TFS
I'm trying to use VC++ 2008 Express (in 32bit XP). I'm told to install WDK
7.1.0 in order to get ATL. After installing WDK and making the "build -cZ",
I added all the necessary folder paths for "Include" and "Library" in VC++
2008 Express. More exactly, I went to Tools menu > Options , then in
"Projects and Solutions" branch > "VC++ Directories" sub-branch, I added the
* C:\WinDDK\7600.16385.1\inc\atl71
* C:\WinDDK\7600.16385.1\inc\api
* C:\WinDDK\7600.16385.1\inc\mfc42
* C:\WinDDK\7600.16385.1\lib\ATL\i386
So far so good, right? Then comes the strange thing that I don't understand.
For some projects which were written in VC++ 2003, 2005 or 2008 (not
express), sometimes I have to add
#pragma comment(lib, "atlthunk.lib")
in source code file, eg in stdafx.h
I understand that this instruction tells the linker to look for atlthunk.lib
file. But why just this file in particular? You see,
atl.lib, atls.lib, atlsd.lib and atlthunk.lib.
The other three lib files are loaded correctly without I need to write
something like
#pragma comment(lib, "atl.lib")
Then why does this atlthunk.lib require us to change source code? Is there
any side-effect is the project is opened in VC++ 2008 full edition again?
_______
When atlwin.h or atlcom.h is included and a certain memroy allocation
function is called, this atlthunk.lib is needed.
Loading...