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