Closed taojinsheng closed 5 years ago
Hi Jinsheng, When you link, can you give the full path to all the static libraries? You are giving g++ the path where to find libraries, but don't actually specify any. e.g.
SEQ=/home/jinsheng_tao/software/SeqLib
g++ $SEQ/bin/libseqlib.a $SEQ/bin/libbwa.a $SEQ/bin/libfml.a $SEQ/bin/libhts.a test.cpp
Hi Jeremiah,
Thank you for your reply.I did what you suggested,but the sam error still coccurs:
[15:27 jinsheng_tao@anchordx ~/code/cpp/readbam]$SEQ=/home/jinsheng_tao/software/SeqLib
[15:29 jinsheng_tao@anchordx ~/code/cpp/readbam]$g++ $SEQ/bin/libseqlib.a $SEQ/bin/libbwa.a $SEQ/bin/libfml.a $SEQ/bin/libhts.a test.cpp
/tmp/ccnSkNAq.o: In function main': test.cpp:(.text+0xc8): undefined reference to
SeqLib::BamReader::BamReader()'
test.cpp:(.text+0x10b): undefined reference to SeqLib::BamReader::Open(std::string const&)' test.cpp:(.text+0x148): undefined reference to
SeqLib::BamReader::Header() const'
test.cpp:(.text+0x15e): undefined reference to SeqLib::BamWriter::SetHeader(SeqLib::BamHeader const&)' test.cpp:(.text+0x1ad): undefined reference to
SeqLib::BamWriter::Open(std::string const&)'
test.cpp:(.text+0x1d4): undefined reference to SeqLib::BamWriter::WriteHeader() const' test.cpp:(.text+0x20c): undefined reference to
SeqLib::BamWriter::WriteRecord(SeqLib::BamRecord const&)'
test.cpp:(.text+0x222): undefined reference to SeqLib::BamReader::GetNextRecord(SeqLib::BamRecord&)' test.cpp:(.text+0x235): undefined reference to
SeqLib::BamWriter::Close()'
test.cpp:(.text+0x244): undefined reference to `SeqLib::BamReader::Close()'
collect2: error: ld returned 1 exit status
/tmp/cc6Oayf5.o: In function main': test.cpp:(.text+0x77): undefined reference to
SeqLib::RefGenome::LoadIndex(std::__cxx11::basic_string<char, std::char_traitsSeqLib::RefGenome::~RefGenome()': test.cpp:(.text._ZN6SeqLib9RefGenomeD2Ev[_ZN6SeqLib9RefGenomeD5Ev]+0x23): undefined reference to
fai_destroy'
collect2: error: ld returned 1 exit status
Hi Jeremiah,
Is there any easier way to use SeqLib in my own program, just like Boost C++ Libraries or something like that?
What I need is just use BWA-MEM in computer memory, so it's wasting time to deal with these annoying compiling issues. Anyway, most users of SeqLib are not compute major.
Hi, Abel Chang,SebLib is already easy to use now although depending on version of g++ and stdlib.Boost is written by computer engineers, not bioinformatical scientists 😄RuiFrom my iPhone------------------ Original ------------------From: Abel Chang notifications@github.comDate: Sun,Dec 17,2017 17:55To: walaj/SeqLib SeqLib@noreply.github.comCc: Subscribed subscribed@noreply.github.comSubject: Re: [walaj/SeqLib] undefined reference to xx error for a test (#20)Hi Jeremiah, Is there any easier way to use SeqLib in my own program, just like Boost C++ Libraries or something like that? What I need is just use BWA-MEM in computer memory, so it's wasting time to deal with these annoying compiling issues. Anyway, most users of SeqLib are not compute major.
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread.
{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/walaj/SeqLib","title":"walaj/SeqLib","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/walaj/SeqLib"}},"updates":{"snippets":[{"icon":"PERSON","message":"@alifare in #20: Hi Jeremiah,\r\n\r\nIs there any easier way to use SeqLib in my own program, just like Boost C++ Libraries or something like that?\r\n\r\nWhat I need is just use BWA-MEM in computer memory, so it's wasting time to deal with these annoying compiling issues. Anyway, most users of SeqLib are not compute major."}],"action":{"name":"View Issue","url":"https://github.com/walaj/SeqLib/issues/20#issuecomment-352244071"}}}
For linking issues, I would refer to the source code for https://github.com/walaj/svaba, https://github.com/walaj/VariantBam and https://github.com/walaj/bxtools, all of which show examples of linking with SeqLib. It would be nice if these were header-only libraries like much of Boost, but alas they are not!
Hello! I have same issue and I don't understand what I'm doing wrong.
I have built SeqLib library and add new environment variables:
C_INCLUDE_PATH=/usr/local/lib/seqlib/SeqLib:/usr/local/lib/seqlib/SeqLib/htslib
CPATH=/usr/local/lib/seqlib/SeqLib:/usr/local/lib/seqlib/SeqLib/htslib
LDFLAGS=/usr/local/lib/seqlib/SeqLib/lib/libseqlib.a /usr/local/lib/seqlib/SeqLib/lib/libbwa.a /usr/local /lib/seqlib/SeqLib/lib/libfml.a /usr/local/lib/seqlib/SeqLib/lib/libhts.a
Here is my sample code:
#include "SeqLib/RefGenome.h"
using namespace SeqLib;
int main(){
RefGenome ref;
BamReader k = BamReader();
k.IsOpen();
return 0;
}
Error:
g++ parq.cpp
/tmp/ccT7AQQy.o: In function `main':
parq.cpp:(.text+0xe5): undefined reference to `SeqLib::BamReader::BamReader()'
/tmp/ccT7AQQy.o: In function `SeqLib::RefGenome::~RefGenome()':
parq.cpp:(.text._ZN6SeqLib9RefGenomeD2Ev[_ZN6SeqLib9RefGenomeD5Ev]+0x23): undefined reference to `fai_destroy'
collect2: error: ld returned 1 exit status
I've also tried specifying full library paths, same error.
Best Regards, Nick
Hi Nick, Can you show me the output of the compiler at the linking step? I suspect your env vars are not being passed to your compiler.
Hi Jeremiah,
Following your intructions,I have successfully installed the library. However,when I tried to test it,I got following error although I specified the static library path: g++ -L/home/jinsheng_tao/software/SeqLib/bin/ test.cpp /tmp/ccGnVDiX.o: In function
main': test.cpp:(.text+0xc8): undefined reference to
SeqLib::BamReader::BamReader()' test.cpp:(.text+0x10b): undefined reference toSeqLib::BamReader::Open(std::string const&)' test.cpp:(.text+0x148): undefined reference to
SeqLib::BamReader::Header() const' test.cpp:(.text+0x15e): undefined reference toSeqLib::BamWriter::SetHeader(SeqLib::BamHeader const&)' test.cpp:(.text+0x1ad): undefined reference to
SeqLib::BamWriter::Open(std::string const&)' test.cpp:(.text+0x1d4): undefined reference toSeqLib::BamWriter::WriteHeader() const' test.cpp:(.text+0x20c): undefined reference to
SeqLib::BamWriter::WriteRecord(SeqLib::BamRecord const&)' test.cpp:(.text+0x222): undefined reference toSeqLib::BamReader::GetNextRecord(SeqLib::BamRecord&)' test.cpp:(.text+0x235): undefined reference to
SeqLib::BamWriter::Close()' test.cpp:(.text+0x244): undefined reference to `SeqLib::BamReader::Close()' collect2: error: ld returned 1 exit statusBelow is my source code:
include <SeqLib/BamReader.h>
include <SeqLib/BamWriter.h>// #include "SeqLib/BWAWrapper.h"
include <SeqLib/BamRecord.h>
using namespace SeqLib;
int main(int argc,char* argv[]) { // open the reader BAM/SAM/CRAM SeqLib::BamReader r; r.Open(argv[1]);
} It would be greatly appreciated if you could help me with this problem.Many thanks.
Best regards, Jinsheng