Bug #3145 mysql_real_escape_string generates an unresolved external in VC++
Submitted: 11 Mar 2004 10:53 Modified: 19 Apr 2004 11:31
Reporter: Daniel Eloff Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.8 OS:Windows (Win)
Assigned to: Assigned Account CPU Architecture:Any

[11 Mar 2004 10:53] Daniel Eloff
Description:
mysql_real_escape_string generates an unresolved external on the VC++ compiler (tested with VC++ 7.1) even with all libs included.

How to repeat:
Try to compile a project that uses mysql_real_escape_string with the visual c++ compiler.

Suggested fix:
Add the function to the lib file I would suspect.
[11 Mar 2004 18:02] MySQL Verification Team
The version you are using is a bit older, however I verified the source
package and noticed that mysql_real_escape_string was exported, please
verify this in your stuff if libmysql.def has this function exported.

Otherwise, could you please show for us the exactly symbols not resolved.

Thanks.
[12 Mar 2004 11:15] Daniel Eloff
Okay it is in the .def file.

The error is not a linker error but a run-time error associated with the dll.

"The procedure entry point mysql_real_escape_string could not be located in the dynamic link library LIBMYSQL.dll"
[12 Mar 2004 11:41] MySQL Verification Team
Could you please provide me a test case code I will try it with
VC++ 7.0 (I don't have VC++ 7.10).
[13 Mar 2004 10:16] Daniel Eloff
Okay just create a new project, go into your project options and add under C++/General the directory of mysql/include wherever that may be on your machine.
Go to the linker and add the mysql/lib/debug/libmySQL.lib or whatever it is called to additional dependencies.

Then try this:

#include <mysql.h>

int main()
{
char * dest = NULL;
const char * from = "string to escape";
mysql_real_escape_string(NULL,dest,from,strlen(from));
}

Yes that should crash when you run it, but since it never finds mysql_real_escape_string in the dll it is my feeling that it will suffice for duplicating the error.
[19 Mar 2004 9:14] MySQL Verification Team
Yes your sample crash due to NULL value for first parameter,
but I did another test and mysql_real_escape_string is called
without problems. How I am using VC++ 6.0 and VC++ 7.0 and
there is the chance with a problem with VC++ 7.10; then I
suggest you to compile yourself with VC++ 7.10 the libmysql
stuff and verify that actually mysql_real_escape_string is
being exported in the libmysql.def file.

Thanks.
[19 Mar 2004 11:03] Daniel Eloff
Ok, how do I do that? Is there a webpage or something that tells me what files I need to add to the project and what compile settings I need?
[19 Mar 2004 11:31] MySQL Verification Team
You can get the source from here:

http://www.mysql.com/downloads/mysql-4.0.html

scroll down for Windows source package.

Notice that you will need convert the project files which were
build with VC++ 6.0
[14 Feb 2005 22:54] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".