Solved

MySQL errno: 2 when registering UDF

Posted on 2014-11-06
16
312 Views
Last Modified: 2014-11-22
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
Comment
Question by:DerekWatling
  • 9
  • 7
16 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40427808
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40427809
errno 2 means in short: file not found
0
 

Author Comment

by:DerekWatling
ID: 40427841
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
 

Author Comment

by:DerekWatling
ID: 40427853
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
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40427855
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40427856
:)
0
 

Author Comment

by:DerekWatling
ID: 40427920
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40427936
did you restart the mysql instance?
can you try to copy the dll into the windows system32 folder?
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:DerekWatling
ID: 40428029
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
 

Author Comment

by:DerekWatling
ID: 40428140
Tried all of the above including putting in Sytem32 with restrting MySQL service inbetween. Consitently getting errno 0 now.
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40428205
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
 

Author Comment

by:DerekWatling
ID: 40428242
Both 64bit.
0
 

Accepted Solution

by:
DerekWatling earned 0 total points
ID: 40446737
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40446934
hard-code stuff :)
0
 

Author Comment

by:DerekWatling
ID: 40447089
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
 

Author Closing Comment

by:DerekWatling
ID: 40459232
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Creating and Managing Databases with phpMyAdmin in cPanel.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now