Skip to content

Commit

Permalink
Fix build instructions for MySQL vs MariaDB
Browse files Browse the repository at this point in the history
  • Loading branch information
collinhundley authored Aug 12, 2016
1 parent b860291 commit 57367fb
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

0 comments on commit 57367fb

Please sign in to comment.