[SRILM User List] Compiling srilm with gcc 4.6.1 (and possibly any versions >= 4.3): patched Lattice sources

Edward Grefenstette egrefen at gmail.com
Wed May 16 09:25:56 PDT 2012


Dear srilm users,

As mentioned in another email, I've encountered and later resolved some problems building srilm with gcc v4.6. The fault, it seems, lays with the makearray declarations used in LatticeIndex.cc and LatticeNgrams.cc found in ./lattice/src/ of the srilm folder.

I've managed to get srilm to compile by "cheating" and using an older version of g++ passed to make with CXX flag, but ideally it'd be better to fix the source to be compliant with C++0x, as enforced by gcc versions >= 4.3 (I think).

I attach to this email the modified LatticeIndex.cc and LatticeNgrams.cc files from srilm 1.6.0 (diffs reproduced at the end of the email), which allowed me to compile srilm using gcc 4.6.1 without passing an older g++ using the CXX flag. Could someone please sanity check the changes? If they're good, it'd be nice to see these files updated in the main distribution so that others don't encounter this frustrating problem when they update their compilers and decide to (re)build srilm.

I've included the output of 'make test' as well (srilm-tests.txt), which shows some occasional differences, although I don't know if that's a result of these modifications or something else on my system.

Best,
Ed


Diff of original LatticeIndex.cc (srilm 1.6.0) with patched version 
===============================================
$ diff Old/LatticeIndex.cc New/LatticeIndex.cc 
78c78
< 	    makeArray(NBestWordInfo, roundedNgram, len + 1);
---
>                NBestWordInfo *roundedNgram = new NBestWordInfo[len + 1];
102a103
>                delete[] roundedNgram;
===============================================

Diff of original LatticeNgrams.cc (srilm 1.6.0) with patched version
===============================================
$ diff Old/LatticeNgrams.cc New/LatticeNgrams.cc
75c75
< 	makeArray(NBestWordInfo, extendedContext, contextLength + 2);
---
>            NBestWordInfo *extendedContext = new NBestWordInfo[contextLength + 2];
165a166,168
>    
>            delete[] extendedContext;
> 
182c185
<     makeArray(VocabIndex, words, NBestWordInfo::length(ngram)+1);
---
>     VocabIndex *words = new VocabIndex[NBestWordInfo::length(ngram)+1];
186a190,191
> 
>     delete[] words;
===============================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20120516/a67e3109/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LatticeIndex.cc
Type: application/octet-stream
Size: 5714 bytes
Desc: not available
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20120516/a67e3109/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20120516/a67e3109/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LatticeNgrams.cc
Type: application/octet-stream
Size: 7543 bytes
Desc: not available
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20120516/a67e3109/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20120516/a67e3109/attachment-0002.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: srilm-tests.txt
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20120516/a67e3109/attachment.txt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20120516/a67e3109/attachment-0003.html>


More information about the SRILM-User mailing list