Skip to content
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.

postgres and mysql shared libs required even when not used #5

Open
def- opened this issue Feb 1, 2018 · 1 comment
Open

postgres and mysql shared libs required even when not used #5

def- opened this issue Feb 1, 2018 · 1 comment

Comments

@def-
Copy link
Contributor

def- commented Feb 1, 2018

When the shared libs are not installed the binary will complain when running, even if you end up just using sqlite.

@samdmarshall
Copy link

i was running into this same problem, and found a work-around for it:

  1. this is the result of the nim stdlib files db_[sqlite|mysql|postgres] that get imported into httpauth to handle the appropriate backend database types. the nim functions call the stdlib functions, which in-turn call the c-functions of their respective libraries. nim defaults to loading these libraries in via dlopen at runtime to satisfy being able to call into them. the implementation details of this are such that if a library that is specified cannot be found, it terminates the process with exit code 1 and a message about not being able to find the library. so to work around that, we need to stop relying on dlopen to satisfy the library requirement.

  2. the unnecessary libraries need to be overridden using the --dynlibOverride flag with the nim compiler:

--dynlibOverride: "(libmysqlclient|libmariadbclient)"
--dynlibOverride: libpq
  1. now instead of using dlopen to load the respective libraries it falls onto the user to supply the necessary linker flags to link the libraries to the binary. if the libraries are not supplied, you will get a bunch of error messages regarding unresolved symbols. these errors can be easily quashed by supplying the flag --warn-unresolved-symbols, thus turning the unresolved symbol errors into mere warnings instead.
--passL: "--warn-unresolved-symbols"

if you use clang instead of gcc then you will have set it as:

--passL: "-Xlinker --warn-unresolved-symbols"

so that the flag gets passed from the driver to the linker correctly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants