[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

MySQL errno: 2 when registering UDF

I am getting the error message
Can't open shared library 'xxx.dll' (errno: 2 )
when registering a MySQL UDF with the following command
CREATE AGGREGATE FUNCTION xxx RETURNS REAL SONAME "xxx.dll";

I have my development machine running Windows 7 Pro x64 and MySQL community server 5.0.67 and want to "move" this to a new server running Windows Server 2012 R2 Standard. I have Installed MySQL community server 5.0.67, backed-up and restored the database to the new server. All working fine. I have a few UDFs I created years ago and need them on the new server as well. I copied the .dll files into the \bin directory, but get the above error when trying to register them.

What does error 2 mean?
0
DerekWatling
Asked:
DerekWatling
  • 9
  • 7
3 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
bin is the wrong folder:
http://dev.mysql.com/doc/refman/5.1/en/create-function-udf.html
The file must be located in the plugin directory. This directory is given by the value of the plugin_dir system variable.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
errno 2 means in short: file not found
0
 
DerekWatlingAuthor Commented:
Keeping in mind that I am running a 5.0 version, where would I verify which is the correct directory? This documentation states the "plugin_dir" system variable was added in MySQL 5.1.2.

I have looked at the Windows system variables and the only thing I can find is that the PATH contains "C:\Program Files\MySQL\MySQL Server 5.0\bin".

Searching the folders on thw working installation these DLLs are only in the "bin" directory.

My directory structure on both installations is very similar:

...
C:\Program Files\MySQL\MySQL Server 5.0
bin
data
    > ...
Docs
include
lib
    > debug
    > opt
share
    > ...
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
DerekWatlingAuthor Commented:
I have found the coressponding 5.0 documentaion which states:
The path name of the plugin directory. This variable was added in MySQL 5.0.67. If the value is nonempty, user-defined function object files must be located in this directory. If the value is empty, the behavior that is used before 5.0.67 applies: The UDF object files must be located in a directory that is searched by your system's dynamic linker.
The version I am using MySQL 5.0.67 :-)
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
http://dev.mysql.com/doc/refman/5.0/en/create-function-udf.html

As of MySQL 5.0.67, the file must be located in the plugin directory. This directory is given by the value of the plugin_dir system variable.

If the value of plugin_dir is empty, the behavior that is used before 5.0.67 applies: The file must be located in a directory that is searched by your system's dynamic linker. For more information, see Section 21.2.2.5, “Compiling and Installing User-Defined Functions”.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
:)
0
 
DerekWatlingAuthor Commented:
I have tried

1.

creating a Windows Environment System Variable
name                 value
plugin_dir          C:\Program Files\MySQL\MySQL Server 5.0\bin
Same error

2.

I then created a plugin subdirectory in "C:\Program Files\MySQL\MySQL Server 5.0\lib" and moved the DLLs in there.
Same error

3.

Removed the system variable
Same error
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
did you restart the mysql instance?
can you try to copy the dll into the windows system32 folder?
0
 
DerekWatlingAuthor Commented:
No.
Yes.

It probably be only be on Monday, as I am in the middle of something else right now.

Thank you for the help and suggestions so far.
0
 
DerekWatlingAuthor Commented:
Tried all of the above including putting in Sytem32 with restrting MySQL service inbetween. Consitently getting errno 0 now.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
it says failed with error 0 ? does not look consistent.
still it is likely a permission issue OR the .dll is 32/64 bit and the mysql is 64/32 bit (not compatbile...)
0
 
DerekWatlingAuthor Commented:
Both 64bit.
0
 
DerekWatlingAuthor Commented:
Using the instructions from http://www.mooreds.com/wordpress/archives/376 as a rough guide, and setting my project target platform as "x64", I re-compiled the udf on the new server. Copied the .dll to "C:\Program Files\MySQL\MySQL Server 5.0\bin" and it works.

My initial attempt at coping the existing dll, which was also compiled as x64 against MySQL 5.0.67, but on Windows Server 2008 R2 just refused to work on Windows Server 2012 R2.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
hard-code stuff :)
0
 
DerekWatlingAuthor Commented:
What I can say is that the process whs a lot smoother using Visual Studio 2013 Pro than when I originally compiled the udf with Visual C++ Express 2008...
0
 
DerekWatlingAuthor Commented:
The problem is somewhere in what it was compiled against. Guy sugested a bitness conflict (32 vs 64) which got hime the points.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now