htslib: undefined reference Error
1
0
Entering edit mode
3.9 years ago
enho ▴ 40

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

samtools htslib vcf cpp c • 2.0k views
ADD COMMENT
1
Entering edit mode

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 REPLY
0
Entering edit mode

Adding -lhts solved the problem, thanks :)

ADD REPLY
0
Entering edit mode

validate my answer please (green mark on the left )

ADD REPLY
1
Entering edit mode
3.9 years ago

-lhts is missing on your command for compiling.

ADD COMMENT

Login before adding your answer.

Traffic: 2838 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6