# Mysql/Ruby on win32, configuration problem

**URL:** <https://rubytalk.org/t/mysql-ruby-on-win32-configuration-problem/1727>\
**Category:** ruby-talk\
**Created:** [12 September 2002 17:00 UTC](https://rubytalk.org/t/mysql-ruby-on-win32-configuration-problem/1727 "2002-09-12T17:00:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_E.C\_Melis](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@Paul\_E.C\_Melis](https://rubytalk.org/u/Paul_E.C_Melis)\
**Post date:** [12 September 2002 17:00 UTC](https://rubytalk.org/t/mysql-ruby-on-win32-configuration-problem/1727/1 "2002-09-12T17:00:42Z")

</div>

Hello,

When trying to build Mysql/Ruby 2.4.2a on win32 using MSVC++, ruby  
extconf.rb kept reporting it couldn’t find mysql\_query() in the mysqlclient  
library. Pointing to the right directory where the lib is located didn’t  
help, even copying the .lib file to the directory where extconf.rb is  
located didn’t work. Using $DEBUG=1 in extconf.rb showed the problem to be a  
linking problem:

checking for mysql\_query() in -lmysqlclient…  
cl -Feconftest -Ic:/prog/ruby16/lib/ruby/1.6/i586-mswin32 -nologo -DNT=1  
-Zi -MD -O2b2xg- -G5 -Ic:/prog/ruby16/include -I/usr/local/include -nologo  
conftest.c mysqlclient.lib user32.lib ad  
vapi32.lib wsock32.lib  
conftest.c  
conftest.obj : error LNK2001: unresolved external symbol \_mysql\_query  
conftest.exe : fatal error LNK1120: 1 unresolved externals

When I changed mkmf.rb to keep a copy of conftest.c, I found it simply  
looked like this:

int main() { return 0; }  
int t() { mysql\_query(); return 0; }

While trying to get this little C snippet to compile and link correctly, I  
found adding #include “mysql.h” at the beginning solved the problem. The  
linker couldn’t find the symbol \_mysql\_query when linking the original  
conftest.c because it has a different call signature (\_\_stdcall instead of  
\_\_cdecl). In that header file the signatures are given and therefore mysql.h  
needs to be included for the extconf.rb configuration to work correctly.

I suspect other packages might have a similar problem on win32, where  
inclusion of certain headers in the conftest.c files is necessary for  
configuration to succeed.  
I also still don’t see how to solve this problem for Mysql/Ruby 😕

Any comments?  
Paul
