building from src on OS/X (and/or installing)
yarko opened this issue · comments
After make
ing on Mac, fails with *.dyld thus:
$ ./gitql 'select author, message, hash from commits where "travis" in message'
dyld: Library not loaded: libgit2.21.dylib
Referenced from: ${GOPATH}/src/github.com/cloudson/gitql/./gitql
Reason: image not found
Abort trap: 6
According to apple developer docs,
you should be able to set any of
LD_LIBRARY_PATH
,
DYLD_LIBRARY_PATH
, or
DYLD_FALLBACK_LIBRARY_PATH
.
but for me (on Sierra 10.12.1), only the last two work.
An alternative not requiring an environment variable is to install the libraries (link them)
in /usr/local/lib
.
Running this post-installation script from the same directory as make
, on Mac works for me. I'll leave it to you to edit the echo
out.
for i in $(PWD)/libgit2/install/lib/lib*
do
targ="$(basename $i)"
bn=$targ
dn="$(dirname $i)"
[ -L "$i" ] && targ="$(readlink $i)"
echo "ln -s $dn/$targ /usr/local/lib/$bn"
done
Note: If you ever run make clean
from the build directory, your installed commands will stop working, so it may be wiser to copy the two main *.dyld
files into /usr/local/bin, and link everything else back to them. Doing that could look something like this:
for i in $(PWD)/libgit2/install/lib/lib*
do
[ -L "$i" ] && echo "ln -s /usr/local/lib/$(readlink $i) /usr/local/lib/${sr}" \
|| echo "cp $i /usr/local/lib"
done
I was with the same problem, @yarko ! I like your solution! Couldn't open a PR? :)
You need cmake
brew install cmake
will help. Also do not forget to set your DYLD_LIBRARY_PATH
variable after installation... Example:
export DYLD_LIBRARY_PATH="${GOPATH}/src/github.com/cloudson/gitql/libgit2/install/lib:${DYLD_LIBRARY_PATH}" # fix this according to your GO
Thank you @yarko 👏 👏
Your tip seems solve this problem. I did a commit and I would like that you and @luizperes help me to review that.
If you guys want to make some change on it or a better way to write it, please let me know.
It looks neat @cloudson! I will check that on my Mac and reply you back!
Hi @cloudson, I tested the fix_required_variable branch and it seems to have been fixed! Congrats!
Cool, I just will try on linux and edit the readme before merge this. Thanks guys.
Thanks again for the suggestions @yarko . I put of one then on makefile and I'm closing this.
Hi @cloudson - must have missed emails from this, just saw this.
Glad you fixed it.
Some nits:
In the Makefile build:
step (prior to install), how can we ensure that people will successfully get a test of ./gitql
working? Perhaps a simple echo
with a hint that "you may need to set DYLD_LIBRARY_PATH" to get the uninstalled version to run? This is more important on an update - if you have a gitql installed, but want to build / test a new version - so probably for more than the benefit of just Mac folks.
Also, would it be worthwhile (since you're copying files into /usr/local) to have a make uninstall
?
Thanks for this patch