string and dll's 
Author Message
 string and dll's

I'm trying to use string(STL) with dll's (VC++ 6.0). If I create a library
that has a class using string's and returning strings back to the caller
everythinf works fine, As soon as a try to create a dll, I get problems.
The compiler first says he needs an instantiation af basic_string<char>..
and so on, as soon as a create one according to the hints'  (Q168958), he
complaint's there is already one. Okay this doesn't really matter.
I still can create the dll and use it. In release mode everythin seems to
work. As soon as a switch to debug mode I get problems:

User breakpoint called from code at ....,
Debug assertion failed ...CrtlsValidHeapPointer(pUserData)
HEAP[testdll.exe]: Invalid Address specified to RtlFreeHeap( 590000,
481990 )

One can go on with ignoring the stuff, but I hate doing this.

Is there a HOWTO for STL and DLL's, and are there examples around.




Tue, 17 Apr 2001 03:00:00 GMT  
 string and dll's
Could you post some sample code?

Michael

Quote:

> I'm trying to use string(STL) with dll's (VC++ 6.0). If I create a library
> that has a class using string's and returning strings back to the caller
> everythinf works fine, As soon as a try to create a dll, I get problems.
> The compiler first says he needs an instantiation af basic_string<char>..
> and so on, as soon as a create one according to the hints'  (Q168958), he
> complaint's there is already one. Okay this doesn't really matter.
> I still can create the dll and use it. In release mode everythin seems to
> work. As soon as a switch to debug mode I get problems:

> User breakpoint called from code at ....,
> Debug assertion failed ...CrtlsValidHeapPointer(pUserData)
> HEAP[testdll.exe]: Invalid Address specified to RtlFreeHeap( 590000,
> 481990 )

> One can go on with ignoring the stuff, but I hate doing this.

> Is there a HOWTO for STL and DLL's, and are there examples around.





Fri, 20 Apr 2001 03:00:00 GMT  
 string and dll's
I found the following article at microsoft:
http://support.microsoft.com/support/kb/articles/q168/9/58.asp?FR=0
It is specifically for vectors and I could not figure out how to apply it to
strings.  If you get this figured out, please post a solution.

thanks,
Jordan



Fri, 20 Apr 2001 03:00:00 GMT  
 string and dll's
Did you get a response to this question?  If so, please post it.

Thanks,
Jordan

Quote:

> I'm trying to use string(STL) with dll's (VC++ 6.0). If I create a library
> that has a class using string's and returning strings back to the caller
> everythinf works fine, As soon as a try to create a dll, I get problems.
> The compiler first says he needs an instantiation af basic_string<char>..
> and so on, as soon as a create one according to the hints'  (Q168958), he
> complaint's there is already one. Okay this doesn't really matter.
> I still can create the dll and use it. In release mode everythin seems to
> work. As soon as a switch to debug mode I get problems:

> User breakpoint called from code at ....,
> Debug assertion failed ...CrtlsValidHeapPointer(pUserData)
> HEAP[testdll.exe]: Invalid Address specified to RtlFreeHeap( 590000,
> 481990 )

> One can go on with ignoring the stuff, but I hate doing this.

> Is there a HOWTO for STL and DLL's, and are there examples around.





Fri, 27 Apr 2001 03:00:00 GMT  
 string and dll's
This sounds like the infamous static-heap runtime library problem.  If you
are linking to the static versions of the C runtime libraries, I suggest
that you try linking to the DLL runtime libraries (for all EXEs and DLLs in
your app), and see if the problem goes away.  If it does, that's the
problem.

The problem would appear most blatantly for for debug builds, and only when
memory allocated with one DLL's version of new/malloc is freed with another
DLL's version of delete/free.  This could easily be the case "under the
hood" for std::string, since it uses copy-on-write internally and may end up
deleting its buffer in somewhat arbitrary places.

By switching to the C run time library DLL, you ensure that all modules in
your process are using the same heap, the same routines, and the same static
data.

John Panzer



Sun, 29 Apr 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Passing Strings via C DLL's and Visual Basic

2. String Handling in DLL's -- HELP PLEASE!

3. Can't find string resource in normal DLL

4. Creating dll's referencing legacy dll's

5. point d'entrée fnovr501 d'une DLL introuvable dans C:\...\ovr501.dll

6. Mixing MFC Extension DLL's with Regular DLL's

7. How to cycle through the strings in the string table of a resource DLL

8. Exporting string from dll using non DLL version of CRT

9. System::String '==' operator

10. finding ':' in a string

11. Strings - managing null character - '\0'

12. Q!!'scanf'ing strings with char**s

 

 
Powered by phpBB® Forum Software