# Compiling mysql-ruby-2.8 problems

**URL:** <https://www.ruby-forum.com/t/compiling-mysql-ruby-2-8-problems/158872>\
**Category:** Ruby\
**Created:** [January 28, 2009, 11:20pm UTC](https://www.ruby-forum.com/t/compiling-mysql-ruby-2-8-problems/158872 "2009-01-28T23:20:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_2k8](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@alex\_2k8](https://www.ruby-forum.com/u/alex_2k8)\
**Post date:** [January 28, 2009, 11:20pm UTC](https://www.ruby-forum.com/t/compiling-mysql-ruby-2-8-problems/158872/1 "2009-01-28T23:20:30Z")

</div>

Hello,

I am trying to compile mysql-ruby-2.8  
([http://rubyforge.org/frs/?group\_id=4550](http://rubyforge.org/frs/?group_id=4550)) on windows, but ‘ruby  
extconf.rb’ reports such error:

* * *

checking for main() in libmysql.lib… no

* * *

The mkmf.log has:

* * *

checked program was:  
/\* begin _/  
1: #define WIN32\_LEAN\_AND\_MEAN  
2: #include \<winsock2.h\>  
3: #include \<windows.h\>  
4:  
5: /top/  
6: int main() { return 0; }  
7: int t() { void ((volatile p)()); p = (void (()()))main; return 0; }  
/_ end \*/

* * *

I see no mysql related headers to be included. I guess they are required  
to declare ‘main’ symbol?

In extconf.rb I see:

* * *

require ‘mkmf’

if /mswin32/ =~ RUBY\_PLATFORM  
inc, lib = dir\_config(‘mysql’)  
exit 1 unless have\_library(“libmysql”)  
elseif …

* * *

have\_library(“libmysql”) specified only the library name but the headers  
parameter is missed. So how it expected to know which mysql headers to  
#include?

Also, this ‘main’ function checked… What is it? Why so odd symbol  
name?

I am so confused… May be some one can clarify things 🙂

Thanks,

- Alex

---

<div class="post-metadata">

**Author:** ![alex\_2k8](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@alex\_2k8](https://www.ruby-forum.com/u/alex_2k8)\
**Post date:** [January 29, 2009, 2:47am UTC](https://www.ruby-forum.com/t/compiling-mysql-ruby-2-8-problems/158872/2 "2009-01-29T02:47:11Z")

</div>

I have compiled it (had wrong environment), but still don’t understand  
how have\_library works. So explanations are welcome 🙂

---

<div class="post-metadata">

**Author:** ![alex\_2k8](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@alex\_2k8](https://www.ruby-forum.com/u/alex_2k8)\
**Post date:** [January 29, 2009, 2:54pm UTC](https://www.ruby-forum.com/t/compiling-mysql-ruby-2-8-problems/158872/3 "2009-01-29T14:54:43Z")

</div>

Alex 2k8 wrote:

> I have compiled it (had wrong environment), but still don’t understand  
> how have\_library works. So explanations are welcome 🙂

Getcha. ‘main’ stands for ‘int main()’ and actually does nothing here,  
as main is always present. The real check for library presense comes  
from linker.

---

<div class="post-metadata">

**Author:** ![alex\_2k8](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@alex\_2k8](https://www.ruby-forum.com/u/alex_2k8)\
**Post date:** [April 6, 2009, 2:15am UTC](https://www.ruby-forum.com/t/compiling-mysql-ruby-2-8-problems/158872/4 "2009-04-06T02:15:30Z")

</div>

Alex 2k8 wrote:

> I have compiled it (had wrong environment), but still don’t understand  
> how have\_library works. So explanations are welcome 🙂

Hello Alex

I m very knew to Ruby, and I m also having similar issue. i.e.  
checking for main() in libmysql.lib… no

Can you please advise on the resolution

Thanks  
Kraz

---

<div class="post-metadata">

**Author:** ![alex\_2k8](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@alex\_2k8](https://www.ruby-forum.com/u/alex_2k8)\
**Post date:** [April 6, 2009, 8:16am UTC](https://www.ruby-forum.com/t/compiling-mysql-ruby-2-8-problems/158872/5 "2009-04-06T08:16:13Z")

</div>

Kz Byz wrote:

> I m very knew to Ruby, and I m also having similar issue. i.e.  
> checking for main() in libmysql.lib… no
> 
> Can you please advise on the resolution

Hi Kz,

In case you are working in Windows then do this.

1. Download the attachment dll from  
[libmysql.dll free download | DLL‑files.com](http://www.dll-files.com/dllindex/dll-files.shtml?libmysql)  
2.SAVE that file into c:\ruby\bin\
2. gem install mysql
3. CHECK your code now…

Regards,  
P.Raveendran

> **[Raveendran](https://raveendran.wordpress.com)**
>
> Nothing is impossible...

---

<div class="post-metadata">

**Author:** ![alex\_2k8](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e9a140/32.png) [@alex\_2k8](https://www.ruby-forum.com/u/alex_2k8)\
**Post date:** [April 6, 2009, 11:51am UTC](https://www.ruby-forum.com/t/compiling-mysql-ruby-2-8-problems/158872/6 "2009-04-06T11:51:04Z")

</div>

Hello, Kraz

The steps to get NMAKE was:

1. Start \> Visual Studio 2008 \> Visual Studio Tools \> Visual Studio  
Command Prompt

2. ruby extconf.rb  
–with-mysql-include=C:\PROGRA~1\MYSQL\MYSQLS~1.1\INCLUDE  
–with-mysql-lib=C:\PROGRA~1\MYSQL\MYSQLS~1.1\LIB\OPT\

Regards,

- Alex
