3

i have have a program/project in vs2008 that uses a third party static lib. Now, it has come to my attention that i need to offer some api's via a dll. Apparently a thrid party program will use my dll via the apis i will provide.

Can anyone give me some direction as to what I need to do? would i need to just create a dll in vs2008 and just copy and paste my method logic in the apis that i provide?

are there any potential issues i need to worry about?

thank you

djones2010
  • 369
  • 2
  • 5
  • 13

1 Answers1

2

I suggest you check out this MSDN tutorial on creating & using DLLs.

There are unfortunately many potential issues to think about. A very brief and by no means complete list of the ones that pop in to my head:

  • You need to be aware of potential errors passing CRT objects across DLL boundaries
  • If you allocate objects in one module and deallocate them in the other, your DLL and the client code must link to the same CRT
  • It is very important that you keep the interface seperate from the implementation in your DLLs header files. This means you often can't do thing like use std::string as function parameters, or even as private member variables.

If I think of more or find more links, I'll add them.

Community
  • 1
  • 1
John Dibling
  • 99,718
  • 31
  • 186
  • 324
  • currently i use std::String everywhere in my code. but i reckon when i do the api iterfaces i would need to use const char * perhaps to do the same thing? – djones2010 Feb 24 '10 at 22:29
  • Yeah, if your functions take string parameters you can & should just use `const char*` parameters instead of `string` s. The functions that return `string`s are more problematic. You need to somehow either allocate a `char` buffer and return a `char*` (you will need to be careful of the second point above) or accept a pre-allocated buffer and fill it in. – John Dibling Feb 25 '10 at 14:46