Exporting std:vector in a class via dll?

Started by
3 comments, last by daerid 18 years ago
Greetings! I was wondering is it possible to export a STL vector via Class in a DLL? For example:

class MYDLLAPI CTest
{
  std::vector<int> m_Table; // problem, not possible?
public:
  CTest();
  ~CTest(); 
};
I have the highest warning level 4 and I can not export souch a class. Without the class it works just fine, but i need a dynamic list in a dll to store any number of input devices attached to the computer. Thank you in advance!
Advertisement
What error message do you get?

Also, if you're exporting STL objects from a DLL, you need you link with the DLL version of the CRT in Windows, or you'll get a crapload of errors about the heap.
Thank you for your post.

I'm in a cyber caffe right now and I can not recall the correct error description. It was about a missing specifier.

I found this article:
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B168958

But I can not check it right away. It seems that STL Containers have to be some kind of pre-defined before usage in DLL.
Interesting, I wasn't aware of that. That MSDN article seems to have all the information you need to get it working though (THe code sample near the bottom).
This is the exact reason that I usually only export interfaces from DLL's, usually with a CreateInstance() type of function.

That way all implementation details are maintained without crossing the DLL boundary.
daerid@gmail.com

This topic is closed to new replies.

Advertisement