linking problems

Andreas Stolcke stolcke at speech.sri.com
Fri Dec 31 12:46:09 PST 2004


Where you able to build the standard "ngram" program in SRILM
without problems?  If so the problems you are having now
are most likely due to a discrepancy in the compiler or linker 
flags used.

Record the command line flags used in SRILM building and linking.
Then use the exact same options when compiling and linking your own 
program.

--Andreas

In message <41D519E2.9040508 at cs.nyu.edu>you wrote:
> Greetings.
> 
> I am new to the toolkit and I am having a big linking problem.  I wrote 
> a program which among other things has the following lines:
> 
>       Vocab *vocab = new Vocab;
>       assert(vocab != 0);
>      
>       ngramLMs[d] =  new Ngram(*vocab, order);
> 
> I then readin a model file and query it.
> 
> However, while linking my program, I get:
> 
> 
> /home/wellingt/dev/MOTE/obj/Linux/NGramModel.o(.text+0x347): In function 
> `NGramModel::NGramModel(std::vector<StringVocabulary*, 
> std::allocator<StringVocabulary*> >, char const*)':
> /usr/include/c++/3.2.3/bits/stl_vector.h:1006: undefined reference to 
> `Vocab::Vocab(unsigned int, unsigned int)'
> /home/wellingt/dev/MOTE/obj/Linux/NGramModel.o(.text+0x41c): In function 
> `NGramModel::NGramModel(std::vector<StringVocabulary*, 
> std::allocator<StringVocabulary*> >, char const*)':
> /home/wellingt/dev/MOTE/src/NGramModel.C:65: undefined reference to 
> `Ngram::Ngram(Vocab&, unsigned int)'
> /home/wellingt/dev/MOTE/obj/Linux/NGramModel.o(.text+0x9fd): In function 
> `NGramModel::NGramModel(std::vector<StringVocabulary*, 
> std::allocator<StringVocabulary*> >, char const*)':
> /home/wellingt/dev/MOTE/src/NGramModel.C:62: undefined reference to 
> `Vocab::Vocab(unsigned int, unsigned int)'
> /home/wellingt/dev/MOTE/obj/Linux/NGramModel.o(.text+0xad2):/home/wellingt/de
> v/MOTE/src/NGramModel.C:65: 
> undefined reference to `Ngram::Ngram(Vocab&, unsigned int)'
> collect2: ld returned 1 exit status
> 
> 
> I have included the library and the headers. 
> I made sure everything that was included in the ngram.cc compilation is 
> also in mine.
>  But while I have no issues compiling ngram.cc, I always get the above 
> errors on my file.
> 
>  the following is in my linking and object file compilation:
> 
> -lflm -ldstruct -lmisc -lm -ldl -ltcl
> -L/home/wellingt/dev/srilm/lib/i686
> -I/home/wellingt/dev/srilm/include
> /home/wellingt/dev/srilm/lm/obj/i686/liboolm.a
> 
> what am I missing?  Any help on this would be appreciated.
> 
> Thank you,
> Benjamin Wellington
> New York University




More information about the SRILM-User mailing list