Groups | Blog | Home
all groups > sql server programming > october 2004 >

sql server programming : Can't get xp_hello sample to work


skissane NO[at]SPAM gmail.com
10/7/2004 11:15:59 PM
Hi,

I try compiling the xp_hello.dll sample using the Visual C++ Toolkit,
as follows:

cl xp_hello.c /I "C:\program files\microsoft sql
server\80\tools\devtools\include" /LD /nologo /MT /W3 /GX /O2 /D
"WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D
"XP_HELLO_EXPORTS" /YX /FD /link /dll /def:xp_hello.def
...\..\..\lib\opends60.lib /machine:I386

When I add to the server and then try to call the extended proc
xp_hello, I get an error 127 that entry point xp_hello can't be
found. But I have checked with depends.exe, and it is being exported
from xp_hello! The builtin extended procs (e.g. those in xpstar.dll)
all work fine, and running depends.exe on xpstar.dll I can't see any
difference between them and xp_hello.dll....

Anyone able to help?

Thanks
Jonathan Chong
10/8/2004 2:28:04 PM
[quoted text, click to view]

Have you do these?
1. Register it in SQL with sp_addextendedproc command.
2. Copy your xp_hello.dll to your SQL Server \Binn directory

skissane NO[at]SPAM gmail.com
10/10/2004 7:28:17 PM
[quoted text, click to view]
Yes, I have copied it to Binn and registered it with
sp_addextendedproc. I know it is loading the DLL, because it gives me
the message:
ODBC: Msg 0, Level 16, State 1
Cannot find the function xp_hello in the library xp_hello.dll. Reason:
127(The specified procedure could not be found.).

Whereas, if I use a non-existent name, e.g. xp_hello2.dll, I get the
different message:
ODBC: Msg 0, Level 16, State 1
Cannot load the DLL xp_hello2.dll, or one of the DLLs it references.
Reason: 126(The specified module could not be found.).

So the problem is not with loading the DLL; rather, it is with finding
the entry point in the DLL. But depends.exe says the entry point is
there.

I have tried both using a .DEF file (the one supplied with the sample
by MS), and with using __declspec(dllexport) before the __GetXpVersion
and xp_hello functions, and neither seems to make a difference. (i.e.
depends.exe reports dll entry point is there, but SQL Server, although
it can find the DLL, it can't find the entry point....)

Thanks
Jonathan Chong
10/11/2004 4:04:22 PM
Check this out
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odssql/ods_6_con_01_26hx.asp
You might be facing the same problem as the link. Hope it helps.

[quoted text, click to view]

skissane NO[at]SPAM gmail.com
10/11/2004 5:07:35 PM
[quoted text, click to view]

Thanks, but unfortunately not much help there either.

The documentation says:
"""" If the name of the function specified in sp_addextendedproc does
not exactly match the function name in the DLL, the new name will be
registered in SQL Server, but the name will not be usable. For
example, although xp_Hello is registered as a SQL Server extended
stored procedure located in xp_hello.dll, SQL Server will not be able
to find the function in the DLL if you use xp_Hello to call the
function later. """"

But, I checked, I am registering it as xp_hello (all lower case) using
sp_addextendedproc, calling it as xp_hello (all lower case), and its
exported from the dll as xp_hello (all lower case).... So that doesn't
seem to be the problem, since I'm using exactly the same case
skissane NO[at]SPAM gmail.com
10/12/2004 7:58:15 AM
[quoted text, click to view]
No, I don't own a copy of that.

I have been using the free Microsoft Visual C++ Toolkit 2003. It is
basically the command line tools (cl.exe) for Visual Studio .NET 2003
C++, but without the IDE.

Could you maybe email me or post on the web your xp_hello.dll, so we
can see if it is my server or my compiler?

Thanks
Jonathan Chong
10/12/2004 11:25:51 AM
Are you using Microsoft Visual C++ 6.0? So far I have been using it to build
and compile extended stored proc without any problem.
May be you can try it from there. Just choose "Extended Stored Procedure
Wizard" in project selection dialog.

[quoted text, click to view]

AddThis Social Bookmark Button