www.delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
To: | cygwin AT cygwin DOT com |
From: | Nicholas Thayer <ndthayer AT comcast DOT net> |
Subject: | Re: MySQL 5.0.21 C API under cygwin |
Date: | Wed, 10 May 2006 15:24:37 -0600 |
Lines: | 51 |
Message-ID: | <e3tlmo$gpe$1@sea.gmane.org> |
References: | <e3tht4$2tg$1 AT sea DOT gmane DOT org> |
Mime-Version: | 1.0 |
User-Agent: | Mozilla Thunderbird 0.9 (Windows/20041103) |
In-Reply-To: | <e3tht4$2tg$1@sea.gmane.org> |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Eric Lilja wrote: > For a long time I've been wanting to compile C/C++ programs that can talk to > a MySQL server under Cygwin. I tried to compile to several version of MySQL > (configuring with the flag --without-server), but the build process always > ended with some error. I also tried to convert the msvc-libraries that come > with the Windows version of MySQL to a MingW-usable format. After a lot of > hassle I could get my programs to link, but the resulting executables > crashed almost right away. Probably some nice stack corruption or some such. > Seeing no other option, I ended up using MSVC to compile my programs that > talk to the native Windows MySQL database. > > But last night I decided to give it another shot. Cygwin had seen alot of > improvements since I last tried and MySQL version 5 (the version I'm > interested in) had also seen several updates. > Using a fully updated Cygwin, I compiled MySQL 5.0.21 with --disable-server > (and some other disables). It compiled cleanly, woot! Then I tried to link a > simple test program compiled using cygwin's gcc. It complained about some > undefined references, but I solved that by linking to zlib (-lz) *after* > linking the mysql libraries. > > Then I started the native Windows MySQL server on the same machine and tried > to connect. The program ended with the following error: Can't connect to > local MySQL server through socket '/tmp/mysql.sock' (2) > > So I the changed mysql_real_connect() call to connect to "127.0.0.1" instead > of "localhost" and specified port 3306 instead 0 and then it worked! My > simple test program created a table and inserted a tuple and it works! > > I just wanted to share this if someone else is wants to do what I want to: > Develop C/C++ programs using Cygwin that talk to a native Windows MySQL > server. > > / E > > > > Eric, I'm chuckling at the synopsis of your process because I went through the exact same series of trials and errors. The issue with the /tmp/mysql.sock is that MySQL uses domain sockets for *NIX machines and named pipes on Windows machines. Specifying the IP address uses TCP/IP sockets, which work as expected. I was compiling the server for the Perl::DBI module, which required libraries and headers to link against. * Nicholas -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |