Sign in to follow this  
Samurai Jack

Exporting std:vector in a class via dll?

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this