fncnt/librna-sys

ViennaRNA/plotting/naview.h file not found

Closed this issue · 5 comments

Hi,

Thank you for creating this crate, I'm not familiar with the rust calling c library. I installed the ViennaRNA at /data01/softwares/ViennaRNA-2.5.1 and the libRNA.a file can be found at /data01/softwares/ViennaRNA-2.5.1/src/ViennaRNA I want to know how to set the LIBRNA_INCLUDE_DIR variable because the cargo keeps telling me that fatal error: 'ViennaRNA/plotting/naview.h' file not found

Best wishes

fncnt commented

Hi, thanks for reaching out!

There are a few things happening here.
First, ViennaRNA 2.5.1 changed the location of that particular header file (ViennaRNA/ViennaRNA@569f647).

Second, for some reason, even if naview.h was at the correct location, we wouldn't find it.
The cause of this is still beyond my understanding a header directory I forgot to include.
However, there is a workaround (additionally to setting LIBRNA_INCLUDE_DIR and LIBRNA_LIB_DIR:

export CPATH=$LIBRNA_INCLUDE_DIR

There's still one major caveat; while debugging, I noticed that librna-sys wouldn't build cargo test wouldn't work with ViennaRNA >=2.5.0 (although crates depending on librna-sys still can create tests with the FFI bindings!).
This is possibly related to ViennaRNA/ViennaRNA@1055687

A workaround for this would be downgrading to 2.4.18 for now and following the user-dir installation instructions, i.e.:

tar -zxvf ViennaRNA-2.4.18.tar.gz
cd ViennaRNA-2.4.18
./configure --prefix=/data01/softwares/ViennaRNA
make install
export LIBRNA_INCLUDE_DIR=/data01/softwares/ViennaRNA/include
export LIBRNA_LIB_DIR=/data01/softwares/ViennaRNA/lib
export CPATH=$LIBRNA_INCLUDE_DIR

This should work until I manage to fix the underlying issues. Sorry for the trouble!

EDIT: changed inaccuracies for future reference.

fncnt commented

Actually, the CPATH workaround might not work for you at all...
Currently I'd recommend installing ViennaRNA via one of the official packages or through bioconda until I fix it:
Have a look at this to get an idea.

fncnt commented

This should be fixed in v0.1.5 which is already live on crates.io.
Feel free to re-open if necessary.

Thanks for your explanation, making such a crate is definitely not easy, since the ViennaRNA is a huge package. If someone just wants to use a sub-module of ViennaRNA-2.5.1 with rust, here is the tip: Follow the C API example of ViennaRNA and make a shared library with g++ then call it from rust.

fncnt commented

If someone just wants to use a sub-module of ViennaRNA-2.5.1 with rust, here is the tip: Follow the C API example of ViennaRNA and make a shared library with g++ then call it from rust.

I don't think this is necessary. The linked libRNA.a library is static and only the functions used on the Rust side will be compiled into the binaries.
However, I omitted a few header files containing new functionality since 2.4.18 to maintain backwards-compatibility until I decide how I want to include them without affecting older versions of ViennaRNA (possibly a new minor release). See #2 for details.