Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MariaDB Compatibility #3

Merged
merged 5 commits into from
Aug 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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