MySQL 5.0.21 C API under cygwin

Larry Hall (Cygwin) reply-to-list-only-lh@cygwin.com
Thu May 11 01:24:00 GMT 2006


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/



More information about the Cygwin mailing list