From 57367fbe29bb5033351575a31ca11c638dce896a Mon Sep 17 00:00:00 2001 From: Collin Hundley Date: Fri, 12 Aug 2016 13:34:26 -0600 Subject: [PATCH] Fix build instructions for MySQL vs MariaDB --- README.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 568dbf4..022fe10 100644 --- a/README.md +++ b/README.md @@ -6,26 +6,35 @@ C module for MySQL **To build on macOS:** ```sh -swift build -Xlinker -L/usr/local/lib +swift build -Xswiftc -I/usr/local/include/mysql -Xlinker -L/usr/local/lib ``` +- `-I` tells the compiler where to find the MySQL header file `mysql.h`. +- `-L` tells the linker where to find MySQL library `libmysqlclient`. + **To build on Linux:** +`swift build` should work normally. + +## MariaDB + +To use MariaDB instead of MySQL, you just need to change a couple of the compiler flags. + +**macOS:** + ```sh -swift build -Xswiftc -I/usr/include/mariadb -Xlinker -L/usr/lib/x86_64-linux-gnu +swift build -Xlinker -L/usr/local/lib -Xswiftc -DMARIADB -Xswiftc -DNOJSON ``` -- `-I` tells the compiler where to find the MariaDB header file `mysql.h` -- `-L` tells the linker where to find MariaDB library. - - On macOS the library is called `libmysqlclient`, and on Linux the library is `libmariadb`. - -## MariaDB +- `-DMARIADB` tells the compiler to link the MariaDB library instead of the MySQL library. +- `-DNOJSON` tells the package to ignore the `JSON` type (not supported as of MariaDB 10.1.16). -To use MariaDB instead of MySQL, add the following compiler flag when building: +**Linux:** ```sh --Xswiftc -DMARIADB +swift build -Xswiftc -I/usr/include/mariadb -Xlinker -L/usr/lib/x86_64-linux-gnu -Xswiftc -DMARIADB -Xswiftc -DNOJSON ``` -- This tells the compiler to link the MariaDB library instead of the MySQL library. +- This simply changes the library/header paths and sets the same compatibility options shown above. +- Note that on macOS the library is called `libmysqlclient`, while on Linux the library is called `libmariadb`.