Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extended Stored Procedure DLL

Status
Not open for further replies.

jerasi

Programmer
Jun 19, 2000
141
CA
Hello.
I am writing an extended stored procedure for SQL server and i ran into the problem of exporting functions from a DLL file.
I started a Win32 Dynamic-Link Library project and selected "A DLL that exports some symbols", I added a .def file into the project and added the names of the functions into it, my functions use the __declspec(dllexport) before each of them.
I am using the LoadLibrary and GetProcAddress function to get to the functions but when i get to the line:
sReturn = (*pfnFunction)("param1", "param2");
I get an error and SQL server disconnects.
Am i not exporting right?

Thank you very much for your time.
Jerasi.
 
generating a DLL result a .dll and a .lib. Add this lib to your project and don't Load/Free the library. Use dll dllimports as you use in dll the dllexports. So you will use the sme .h file.

but in declaring function/classes/variables in .h you will
#if defined(dll_implementation)
#define __dllapi __declspec(dllexport)
#else
#define __dllapi __declspec(dllimport)
#endif

__dllapi int xxxx();

on implementing the dll, in all .cpp files you will
#define dll_implementation //in the first line!!!!
so theese declarations will be threated in the dll as export. In the client of dll implementation declare nothing, just #include that .h you used in dll.
John Fill
1c.bmp


ivfmd@mail.md
 
I added the .lib and .h files from my dll I created to my project, I did something like this:
LPCTSTR sErrors = "";
CmyClass *pPtr = new CmyClass;
sReturn = pPtr->FunctionFromDLL("param1", "param2");
delete pPtr ;
This compiles but i get a linking error:
error LNK2001: unresolved external symbol "__declspec(dllimport) public: char const * __thiscall CmyClass::FunctionFromDLL(char const *,char const *)" (__imp_?FunctionFromDLL@CXQL@@QAEPBDPBD0@Z)

Thank you.
 
put the dll in the current projects directory or in a default windows path. John Fill
1c.bmp


ivfmd@mail.md
 
something more, the .lib you should add in Project->Settings->Link->Object/Library modules. John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top