C module for MySQL
To build on macOS:
swift build -Xswiftc -I/usr/local/include/mysql -Xlinker -L/usr/local/lib
-I
tells the compiler where to find the MySQL header filemysql.h
.-L
tells the linker where to find MySQL librarylibmysqlclient
.
To build on Linux:
swift build
should work normally.
To use MariaDB instead of MySQL, you just need to change a couple of the compiler flags.
macOS:
swift build -Xlinker -L/usr/local/lib -Xswiftc -DMARIADB -Xswiftc -DNOJSON
-DMARIADB
tells the compiler to link the MariaDB library instead of the MySQL library.-DNOJSON
tells the package to ignore theJSON
type (not supported as of MariaDB 10.1.16).
Linux:
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 calledlibmariadb
.
Join the welcoming community of fellow Vapor developers in slack.
This package has been tested on macOS and Ubuntu.