brentp / hts-nim-tools

useful command-line tools written to showcase hts-nim
https://github.com/brentp/hts-nim
MIT License
49 stars 6 forks source link

could not import: sam_hdr_destroy #10

Closed telatin closed 4 years ago

telatin commented 4 years ago

Hi there, first of all, thank you very much for this repository! You made me curious about nim some times ago and I gave it a try yesterday for the first time and I already love it.

I tried building the tool of this repository, I don't get compilation errors but at runtime:

could not import: sam_hdr_destroy

this happened both under macOS Catalina and ubuntu 16.04. In both cases automatic installation (via nimble task named_build) of c2nim failed, but nimble install c2nim didn't. Any hints?

Thanks again

telatin commented 4 years ago

Update: I read installation instructions from https://github.com/brentp/hts-nim and with your tool hts_nim_static_builder I managed to compile the program :)

Since my understanding is that nim is evolving quickly (and I'm an absolute beginner), do you still recommend this or there are more "native" alternatives to bundle htslib.so? Thanks

brentp commented 4 years ago

the reason for that import error is that you have an older version of htslib. if you update your htslib, then you will be able to use your system htslib.so.

brentp commented 4 years ago

Did you get this to work with updated htslib? Let me know if you have any issues.

telatin commented 4 years ago

I'm still finding my way around, thanks for checking.

To find my way, I tried:

sudo docker run --rm -ti continuumio/miniconda3

conda search -c conda-forge nim
conda search -c bioconda htslib=1.9
nimble install docopt lapper hts kexpr
nimble install c2nim
# for mysterious reasons: it didnt go at the first attempt, and when trying with verbose to check what was the problem, it was installed
nimble install c2nim --verbose 
nimble c --out:bin/hts src/hts_nim_tools

./bin/hts 

This returned me: could not import: hts_check_EOF, which is different from the could not load: libhts.so I got before installing htslib. Is htslib 1.9 not recent enough? Thanks for you help!

brentp commented 4 years ago

you will need htslib >= 1.10

brentp commented 4 years ago

see note here: https://github.com/brentp/hts-nim#v0223-of-hts-nim-will-be-the-last-version-that-supports-htslib-below-110-which-was-release-in-early-december-2019the-master-branch-requires-htslib-110-and-higher-and-will-be-backward-incompatible-with-previous-releases

telatin commented 4 years ago

Stupid me! I tried with a conda installation but i had some incompatibilities trying with 1.10.x.

Beside your useful container, would it be easy to statically link htslib when compiling with nim? Thanks again, you are making my nim journey easy and useful

brentp commented 4 years ago

it's a bit hard to fully statically link htslib as it depends on lzma, curl, etc. so in the docker container called by the container, i know where everything is. you could try to get all those and passl them as i do in the container: https://github.com/brentp/hts-nim/blob/master/docker/docker.nim.cfg

but you should be able to build binaries that will work on systems with libhts.so (and it's dependencies) simply using nim c and you can always static link only htslib with nim c --passl:/path/to/libhts.a --dynlibOverride:hts

hope that helps.

telatin commented 4 years ago

I'm really happy with the container, thanks! It was a general question (i.e. to compile natively from mac), and your guidance was once again very useful! Best!