linking problems with the STL using IFS Kit settings

Greetings.

I’m using the IFS Kit to write a file system minifilter driver. I’ve
been incorporating some C++ routines into it, and things work great
until I use the string class of the STL. Then, as soon as I have a
class that implies a destructor of a string, the linker explodes.
Here’s the tail of the output of NMAKE:

C:\WINDDK\3790~1.183\lib\wxp\i386\BufferOverflowU.lib
C:\WINDDK\3790~1.183\lib\crt\i386\msvcrt.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\advapi32.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\kernel32.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\fltLib.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\sehupd.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\shell32.lib

widget.obj : error LNK2019: unresolved external symbol
“__declspec(dllimport) public: __thiscall
std::basic_string,class
std::allocator >::~basic_stringstd::char_traits,class std::allocator >(void)”
(_imp??1?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@
QAE@XZ)
referenced in function “public: void__thiscall Fred::dump(class
std::basic_string,class
std::allocator > const &)const “
(?xxxxx@Fred@@QBEXABV?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D
@2@@std@@@Z)

widget.obj : error LNK2019: unresolved external symbol
”__declspec(dllimport) public:__thiscall
std::basic_string,class
std::allocator >::basic_stringstd::char_traits,class std::allocator >(class
std::basic_string,class
std::allocator > const &)”
(_imp??0?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@
xxxxx@ABV01@@Z)
referenced in function "public: void__thiscall Fred::dump(class
std::basic_string,class
std::allocator > const &)const "
(?xxxxx@Fred@@QBEXABV?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D
@2@@std@@@Z)

objfre_wxp_x86\i386\analysis.exe : fatal error LNK1120: 2 unresolved
externals
NMAKE : fatal error U1077: ‘link’ : return code ‘0x460’
Stop.

From what I’ve read by googling for ‘LNK2019 basic_string’, this
happens when my libraries have version mismatches, such as the libs
being built with MSVC 6 and the code with MSVC 7, due to changes in
the structure of basic_string in Microsoft’s implementation. The
solution for this is to “rebuild your libraries.”

But I’m using the default IFS Kit. This is on Win XP SP2, and I
selected the “Windows XP Free Build Environment” from the start
menu. Even if I could somehow rebuild Microsoft’s libraries, I
don’t understand how there could be a mismatch, since my binaries
and my libraries are all from the same development kit.

I do have other development environments on this machine, but the
previous DDK was fully uninstalled before the IFS was installed, and I
have verified that the “Windows XP Free Build Environment” is only
using things in C:\WINDDK\3790.1830 for includes and libraries. (I
even placed an “#error 1” in the inc\crt\string file underneath the
above directory and compilation aborted like one would expect.) And
I’ve compared version numbers for both CL.EXE and LINK.EXE (13.10.4035
and 7.10.4035, if it matters.)

I saw Microsoft’s KB article Q309801 and tried using explicit template
instantiations as they hinted at, by adding these lines:

template class __declspec(dllimport) std::basic_string std::char_traits, class std::allocator >;

but that had no change whatsoever on the results.

I’ve tried using many of the other deveopment shells and doing clean
builds with them, but that had no effect (besides changing the path of
the libraries being used).

What next steps should I take to figure out my problem?

I went round and round with this. I gave up and built with VC 2005
finally. Just add the fltmgr user headers and lib paths to
it’s directory search path. Using the Srv03 sp1 sdk files with the
fltmgr files works fine (at least so far :slight_smile: ). I had these same problems
with STL - I feel your pain.

m.

P.S. you are talking about the user app right? Certainly your not using
C++ in a driver are you? If so, that would be the problem with
the destructor…

Dan Weber wrote:

Greetings.

I’m using the IFS Kit to write a file system minifilter driver. I’ve
been incorporating some C++ routines into it, and things work great
until I use the string class of the STL. Then, as soon as I have a
class that implies a destructor of a string, the linker explodes.
Here’s the tail of the output of NMAKE:

C:\WINDDK\3790~1.183\lib\wxp\i386\BufferOverflowU.lib
C:\WINDDK\3790~1.183\lib\crt\i386\msvcrt.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\advapi32.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\kernel32.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\fltLib.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\sehupd.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\shell32.lib

widget.obj : error LNK2019: unresolved external symbol
“__declspec(dllimport) public: __thiscall
std::basic_string,class
> std::allocator >::~basic_string> std::char_traits,class std::allocator >(void)”
> (_imp??1?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@QAE@XZ)
> referenced in function "public: void__thiscall Fred::dump(class
> std::basic_string,class
> std::allocator > const &)const "
> (?xxxxx@Fred@@QBEXABV?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@@Z)
>
> widget.obj : error LNK2019: unresolved external symbol
> “__declspec(dllimport) public:__thiscall
> std::basic_string,class
> std::allocator >::basic_string> std::char_traits,class std::allocator >(class
> std::basic_string,class
> std::allocator > const &)”
> (_imp??0?$basic_string@
> DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@xxxxx@ABV01@@Z)
> referenced in function "public: void__thiscall Fred::dump(class
> std::basic_string,class
> std::allocator > const &)const "
> (?xxxxx@Fred@@QBEXABV?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@@Z)
>
> objfre_wxp_x86\i386\analysis.exe : fatal error LNK1120: 2 unresolved
> externals
> NMAKE : fatal error U1077: ‘link’ : return code ‘0x460’
> Stop.
>
> From what I’ve read by googling for ‘LNK2019 basic_string’, this
> happens when my libraries have version mismatches, such as the libs
> being built with MSVC 6 and the code with MSVC 7, due to changes in
> the structure of basic_string in Microsoft’s implementation. The
> solution for this is to “rebuild your libraries.”
>
> But I’m using the default IFS Kit. This is on Win XP SP2, and I
> selected the “Windows XP Free Build Environment” from the start
> menu. Even if I could somehow rebuild Microsoft’s libraries, I
> don’t understand how there could be a mismatch, since my binaries
> and my libraries are all from the same development kit.
>
> I do have other development environments on this machine, but the
> previous DDK was fully uninstalled before the IFS was installed, and I
> have verified that the “Windows XP Free Build Environment” is only
> using things in C:\WINDDK\3790.1830 for includes and libraries. (I
> even placed an “#error 1” in the inc\crt\string file underneath the
> above directory and compilation aborted like one would expect.) And
> I’ve compared version numbers for both CL.EXE and LINK.EXE (13.10.4035
> and 7.10.4035, if it matters.)
>
> I saw Microsoft’s KB article Q309801 and tried using explicit template
> instantiations as they hinted at, by adding these lines:
>
> template class __declspec(dllimport) std::basic_string> std::char_traits, class std::allocator >;
>
> but that had no change whatsoever on the results.
>
> I’ve tried using many of the other deveopment shells and doing clean
> builds with them, but that had no effect (besides changing the path of
> the libraries being used).
>
> What next steps should I take to figure out my problem?
>
>
> — Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17 You are currently
> subscribed to ntfsd as: unknown lmsubst tag argument: ‘’ To
> unsubscribe send a blank email to xxxxx@lists.osr.com

Write your own string class instead of STL one, better a wrapper around
UNICODE_STRING, so casting to UNICODE_STRING will be easy.

This is the best way I think. Several hours, and no more issues.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Dan Weber”
To: “Windows File Systems Devs Interest List”
Sent: Friday, April 21, 2006 10:11 AM
Subject: [ntfsd] linking problems with the STL using IFS Kit settings

Greetings.

I’m using the IFS Kit to write a file system minifilter driver. I’ve
been incorporating some C++ routines into it, and things work great
until I use the string class of the STL. Then, as soon as I have a
class that implies a destructor of a string, the linker explodes.
Here’s the tail of the output of NMAKE:

C:\WINDDK\3790~1.183\lib\wxp\i386\BufferOverflowU.lib
C:\WINDDK\3790~1.183\lib\crt\i386\msvcrt.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\advapi32.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\kernel32.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\fltLib.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\sehupd.lib
C:\WINDDK\3790~1.183\lib\wxp\i386\shell32.lib

widget.obj : error LNK2019: unresolved external symbol
“__declspec(dllimport) public:__thiscall
std::basic_string,class
std::allocator >::~basic_stringstd::char_traits,class std::allocator >(void)”
(_imp??1?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@
QAE@XZ)
referenced in function “public: void__thiscall Fred::dump(class
std::basic_string,class
std::allocator > const &)const “
(?xxxxx@Fred@@QBEXABV?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D
@2@@std@@@Z)

widget.obj : error LNK2019: unresolved external symbol
”__declspec(dllimport) public:__thiscall
std::basic_string,class
std::allocator >::basic_stringstd::char_traits,class std::allocator >(class
std::basic_string,class
std::allocator > const &)”
(_imp??0?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@
xxxxx@ABV01@@Z)
referenced in function "public: void__thiscall Fred::dump(class
std::basic_string,class
std::allocator > const &)const "
(?xxxxx@Fred@@QBEXABV?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D
@2@@std@@@Z)

objfre_wxp_x86\i386\analysis.exe : fatal error LNK1120: 2 unresolved
externals
NMAKE : fatal error U1077: ‘link’ : return code ‘0x460’
Stop.

From what I’ve read by googling for ‘LNK2019 basic_string’, this
happens when my libraries have version mismatches, such as the libs
being built with MSVC 6 and the code with MSVC 7, due to changes in
the structure of basic_string in Microsoft’s implementation. The
solution for this is to “rebuild your libraries.”

But I’m using the default IFS Kit. This is on Win XP SP2, and I
selected the “Windows XP Free Build Environment” from the start
menu. Even if I could somehow rebuild Microsoft’s libraries, I
don’t understand how there could be a mismatch, since my binaries
and my libraries are all from the same development kit.

I do have other development environments on this machine, but the
previous DDK was fully uninstalled before the IFS was installed, and I
have verified that the “Windows XP Free Build Environment” is only
using things in C:\WINDDK\3790.1830 for includes and libraries. (I
even placed an “#error 1” in the inc\crt\string file underneath the
above directory and compilation aborted like one would expect.) And
I’ve compared version numbers for both CL.EXE and LINK.EXE (13.10.4035
and 7.10.4035, if it matters.)

I saw Microsoft’s KB article Q309801 and tried using explicit template
instantiations as they hinted at, by adding these lines:

template class __declspec(dllimport) std::basic_string std::char_traits, class std::allocator >;

but that had no change whatsoever on the results.

I’ve tried using many of the other deveopment shells and doing clean
builds with them, but that had no effect (besides changing the path of
the libraries being used).

What next steps should I take to figure out my problem?


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Make sure you say USE_STL=1 in your sources file.
And if you are building some of your own static .libs, make sure the
“USE_MSVCRT=1” vs. “USE_LIBCMT=1” settings are consistent between your .libs
and their clients.
Beware, some versions of STL have threading problems.

I had a medium sized “legacy” code base using no string class and I tried a
few things.

NT STRING type.
Nice to avoid the strlen calls, good for constant strings, but too limited
in length (64k), and you still have to write a library around it, the Rtl
stuff is too incomplete and inconsistent, sometimes allocating memory for
but usually not.

std::string
Nice except I don’t know how to get a writable pointer into them, like to
have GetFullPathName store the result in it.

ATL::CString (or MFC)
Just right.
Too bad it traffics in int instead of size_t, but ok.
It solves the GetFullPathName problem well.
As well you pass the result of GetBuffer to things like _strlwr.
As well there is CStringA and CStringW that can be constructed from each
other, like in legacy code that isn’t all Unicode.
Do accept that you can get exceptions for out of memory or failing to
construct CStringA from CStringW due to conversion failing. std::string also
implies exceptions for low memory.

On the other hand I have converted fixed sized arrays to std::vector, no
problem, and no problems with std::set or std::map – eliminating various
instances of linear search.

True that interop with UNICODE_STRING might merit a custom class that wraps
a UNICODE_STRING. My code was ok with null terminated strings and Win32.

  • Jay

on 4/23/06 10:00 PM, Windows File Systems Devs Interest List digest at
xxxxx@lists.osr.com wrote:

NTFSD Digest for Sunday, April 23, 2006.

  1. Re: linking problems with the STL using IFS Kit settings
  2. Re: fast io try/except
  3. RE: Adding a header to the file while it is being written.
  4. Re: fast io try/except
  5. Re: SharedCacheMap getting set to zero…
  6. RE: SharedCacheMap getting set to zero…

Subject: Re: linking problems with the STL using IFS Kit settings
From: “Maxim S. Shatskih”
> Date: Sun, 23 Apr 2006 17:04:56 +0400
> X-Message-Number: 1
>
> Write your own string class instead of STL one, better a wrapper around
> UNICODE_STRING, so casting to UNICODE_STRING will be easy.
>
> This is the best way I think. Several hours, and no more issues.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
> ----- Original Message -----
> From: “Dan Weber”
> To: “Windows File Systems Devs Interest List”
> Sent: Friday, April 21, 2006 10:11 AM
> Subject: [ntfsd] linking problems with the STL using IFS Kit settings
>
>
> Greetings.
>
> I’m using the IFS Kit to write a file system minifilter driver. I’ve
> been incorporating some C++ routines into it, and things work great
> until I use the string class of the STL. Then, as soon as I have a
> class that implies a destructor of a string, the linker explodes.
> Here’s the tail of the output of NMAKE:
>
>
> C:\WINDDK\3790~1.183\lib\wxp\i386\BufferOverflowU.lib
> C:\WINDDK\3790~1.183\lib\crt\i386\msvcrt.lib
> C:\WINDDK\3790~1.183\lib\wxp\i386\advapi32.lib
> C:\WINDDK\3790~1.183\lib\wxp\i386\kernel32.lib
> C:\WINDDK\3790~1.183\lib\wxp\i386\fltLib.lib
> C:\WINDDK\3790~1.183\lib\wxp\i386\sehupd.lib
> C:\WINDDK\3790~1.183\lib\wxp\i386\shell32.lib
>
> widget.obj : error LNK2019: unresolved external symbol
> “__declspec(dllimport) public:__thiscall
> std::basic_string,class
> std::allocator >::~basic_string> std::char_traits,class std::allocator >(void)”
> (_imp??1?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@
> QAE@XZ)
> referenced in function "public: void__thiscall Fred::dump(class
> std::basic_string,class
> std::allocator > const &)const "
> (?xxxxx@Fred@@QBEXABV?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D
> @2@@std@@@Z)
>
> widget.obj : error LNK2019: unresolved external symbol
> “__declspec(dllimport) public:__thiscall
> std::basic_string,class
> std::allocator >::basic_string> std::char_traits,class std::allocator >(class
> std::basic_string,class
> std::allocator > const &)”
> (_imp??0?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D@2@@std@@
> xxxxx@ABV01@@Z)
> referenced in function "public: void__thiscall Fred::dump(class
> std::basic_string,class
> std::allocator > const &)const "
> (?xxxxx@Fred@@QBEXABV?$basic_string@DU?$xxxxx@xxxxx@std@@V?$allocator@D
> @2@@std@@@Z)
>