1

I want to use libmysqlclient on a project cross compiled to Windows via mingw. In order to link my program, I need "mysqlclient.a" but I'm not able to get it.

I tried to create makefiles for mingw on windows for mysql client, but the configuration step fail.


I was finaly able to build it... using mingw on Windows.

Here are the steps:

  1. Install cygwin
  2. Install packages make, gcc, g++, cmake and cygidn in your cygwin
  3. Download & uncompress libmysql source code
  4. Edit file strings/dtoa.c and replace all occurance of dtoa to something else like _dtoa to prevent conflicts
  5. cd to the package base
  6. type cmake -G "Unix Makefiles" in mingw
  7. make
  8. make install
  9. edit C:\cygwin\usr\local\mysql\include\mysql.h and add #include <winsock.h> /* Bug win32 */ after #define _mysql_h
  10. You can get your files in "C:\cygwin\usr\local\mysql"

I get "libmysqlclient.a" and "liblibmysql.dll.a" and I link my program with them but I still get linker error. What's wrong ? But I still get linking error !

strings libmysqlclient.a | grep _mysql_ping returns a result while the linker complains about undefined reference to `_mysql_ping@4'

Congelli501
  • 2,403
  • 2
  • 27
  • 28

2 Answers2

0

MinGW and Cygwin are often not compatible. You have to build a MySQL client in a 100% MinGW environment.

Scott
  • 21,211
  • 8
  • 65
  • 72
0

With MinGW, you are encouraged to use Windows *.lib files.

Download and install the MySQL Connector/C binary for your Windows platform (32bit or 64bit)

Then compile and link your program accordingly:

g++ myprog.cpp \
-I"C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" \
-L"C:\Program Files\MySQL\MySQL Connector C 6.1\lib" -lmysql
ManuelAtWork
  • 2,198
  • 29
  • 34