Question: htslib: undefined reference Error
0
gravatar for noshadho
3 months ago by
noshadho0
noshadho0 wrote:

Hi Everyone,

I've been stuck with this problem for over a day now and I searched everywhere, I couldn't find any solution for this problem.

I am trying to use htslib and I have a very simple code:

#include <stdio.h>
#include <stdlib.h>
#include "/data/miniconda3/include/htslib/vcf.h"
#include "/data/miniconda3/include/htslib/hts.h"


int main(int argc, char **argv) {
    htsFile *fp = hts_open(argv[1],"r");

    return 0;
}

When I run this code, I get this error:

main.c:(.text+0x23): undefined reference to `hts_open' collect2:
error: ld returned 1 exit status

I tried it on two different system both have RHEL as their os and gcc's updated.

Does anyone know what can be the problem and how can I solve it?

Thanks

htslib samtools c++ C vcf • 156 views
ADD COMMENTlink written 3 months ago by noshadho0
1

Can you please add the command you're using to compile? You may need to link to a library or a directory containing said library object.

ADD REPLYlink written 3 months ago by Alex Reynolds30k

Adding -lhts solved the problem, thanks :)

ADD REPLYlink written 3 months ago by noshadho0

validate my answer please (green mark on the left )

ADD REPLYlink written 3 months ago by Pierre Lindenbaum130k
1
gravatar for Pierre Lindenbaum
3 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum130k wrote:

-lhts is missing on your command for compiling.

ADD COMMENTlink written 3 months ago by Pierre Lindenbaum130k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 713 users visited in the last hour