• Advertisement
Sign in to follow this  

Exporting std:vector in a class via dll?

This topic is 4325 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement