Skip to content

Commit

Permalink
Merge pull request #3 from collinhundley/master
Browse files Browse the repository at this point in the history
MariaDB Compatibility
  • Loading branch information
tanner0101 authored Aug 15, 2016
2 parents 6db7362 + 57367fb commit 5aff814
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
# Qutheory - CMySQL - (Not Tested)
# CMySQL
C module for MySQL

## Install MySQL via Brew (OS X)
follow link to download page http://dev.mysql.com/downloads/mysql/
## Building

You may need to use the following command to build if you experience errors.
**To build on macOS:**

```sh
swift build -Xswiftc -I -Xswiftc /usr/local/mysql/include/ -Xlinker -L -Xlinker /usr/local/mysql/lib/
swift build -Xswiftc -I/usr/local/include/mysql -Xlinker -L/usr/local/lib
```

## Install MySQL via APT-GET (Linux)
- `-I` tells the compiler where to find the MySQL header file `mysql.h`.
- `-L` tells the linker where to find MySQL library `libmysqlclient`.

* Update your system (you may need ```sudo```):
```
apt-get update
apt-get upgrade
```
**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.

* To install MySQL ...
**macOS:**

```sh
swift build -Xlinker -L/usr/local/lib -Xswiftc -DMARIADB -Xswiftc -DNOJSON
```
apt-get install mysql-server

- `-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).

**Linux:**

```sh
swift build -Xswiftc -I/usr/include/mariadb -Xlinker -L/usr/lib/x86_64-linux-gnu -Xswiftc -DMARIADB -Xswiftc -DNOJSON
```

- 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`.

6 changes: 6 additions & 0 deletions module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ module CMySQLLinux [system] {
export *
}

module CMariaDBLinux [system] {
header "/usr/include/mariadb/mysql.h"
link "mariadb"
export *
}

module CMySQLMac [system] {
header "/usr/local/include/mysql/mysql.h"
link "mysqlclient"
Expand Down

0 comments on commit 5aff814

Please sign in to comment.