X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: "Eric Lilja" Subject: MySQL 5.0.21 C API under cygwin Date: Wed, 10 May 2006 22:19:48 +0200 Lines: 34 Message-ID: X-IsSubscribed: yes 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 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 -- 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/