X-Spam-Check-By: sourceware.org Message-ID: <44629229.6080007@cygwin.com> Date: Wed, 10 May 2006 21:23:53 -0400 From: "Larry Hall (Cygwin)" Reply-To: cygwin AT cygwin DOT com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051223 Fedora/1.5-0.2.fc4.remi Thunderbird/1.5 Mnenhy/0.7.3.0 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: MySQL 5.0.21 C API under cygwin References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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. Thanks for the feedback. We like to hear about success stories, at least every now and then. :-) -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746 -- 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/