FreeLing 4.2 — Build fixes for ARM64 (Raspberry Pi 5)
Summary
FreeLing 4.2 fails to build from source on ARM64 (tested on Raspberry Pi 5, 8GB,
running Raspberry Pi OS Bookworm 64-bit, GCC 14.2, ICU 76.1). The following fixes
are required. All can be applied before running cmake.
Environment
- Hardware: Raspberry Pi 5 (8GB RAM)
- OS: Raspberry Pi OS Bookworm 64-bit (Debian-based, aarch64)
- Compiler: GCC 14.2.0
- CMake: 3.31.6
- Boost: 1.83.0
- ICU: 76.1
- SWIG: 4.3.0 (for Python bindings)
Fix 1 — CMakeLists.txt: upgrade C++ standard from 11 to 17
ICU 76.x requires C++17. The hardcoded set(CMAKE_CXX_STANDARD 11) causes
compilation to fail with errors like 'is_convertible_v' is not a member of 'std'.
File: CMakeLists.txt, line ~5
# Before
set(CMAKE_CXX_STANDARD 11)
# After
set(CMAKE_CXX_STANDARD 17)
Fix 2 — src/libdynet/dynet/mem.cc: remove x86-specific memory functions
mm_malloc.h is x86-only and does not exist on ARM64. Replace with standard
equivalents.
File: src/libdynet/dynet/mem.cc
// Before
#include <mm_malloc.h>
// ...
void* ptr = _mm_malloc(n, align);
// ...
_mm_free(mem);
// After
#ifdef __x86_64__
#include <mm_malloc.h>
#endif
// ...
void* ptr = aligned_alloc(align, n);
// ...
free(mem);
Fix 3 — src/libtreeler/treeler/base/scores.h: remove const from mutable member
GCC 14 correctly rejects assignment to a const member via set_score().
File: src/libtreeler/treeler/base/scores.h, line ~85
// Before
const double _s;
// After
double _s;
Fix 4 — Missing #include <cmath> in multiple files
Several source files use log, fabs, sqrt etc. without including <cmath>,
which GCC 14 no longer tolerates. Add #include <cmath> to the top of each:
src/include/freeling/morfo/smoothingLD.h
src/libfreeling/csr_kb.cc
src/libfreeling/numbers/numbers_cs.cc
src/libfreeling/output/output_freeling.cc
src/libfreeling/semdb.cc
src/libfreeling/maco.cc
src/libfreeling/hmm_tagger.cc
src/libfreeling/analyzer_config.cc
src/libfreeling/accents/accents_gl.cc
src/libfreeling/analyzer.cc
src/libfreeling/coref/relaxcor/relaxcor_fex_dep.cc
src/libfreeling/coref/relaxcor/relaxcor_fex_constit.cc
src/libfreeling/coref/adaboost/coref_fex.cc
src/libfreeling/dependency_parsing/dep_lstm.cc
src/libfreeling/tagset.cc
src/libfreeling/dates/dates_ru.cc
src/libfreeling/summarizer/summarizer.cc
src/libfreeling/omlet/libsvm.cc
src/libfreeling/omlet/viterbi.cc
src/libfreeling/ner_module.cc
Quick fix using Python:
python3 -c "
import os
files = [
'src/include/freeling/morfo/smoothingLD.h',
'src/libfreeling/csr_kb.cc',
# ... (add all files above)
]
for f in files:
content = open(f).read()
if '#include <cmath>' not in content:
open(f, 'w').write('#include <cmath>\n' + content)
print('Fixed:', f)
"
Fix 5 — src/libfreeling/analyzer.cc: narrowing conversion of EOF
EOF is -1 (signed int) being assigned to an unsigned type, which GCC 14
treats as an error in C++17 mode.
File: src/libfreeling/analyzer.cc, line ~402
// Before
case EOF:
// After
case (unsigned int)EOF:
Fix 6 — Python bindings (APIs/python3/CMakeLists.txt): enforce C++17
The SWIG-generated Python binding code needs C++17 explicitly, as it doesn't
inherit the top-level standard setting.
File: APIs/python3/CMakeLists.txt — add at end:
set_property(TARGET _pyfreeling PROPERTY CXX_STANDARD 17)
Build commands (after applying fixes)
mkdir build && cd build
cmake .. -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="-std=c++17" -DPYTHON3_API=ON
make -j4
sudo make install
Language data
The Catalan language data is not included in FreeLing-src-4.2.tar.gz.
Download and extract FreeLing-langs-src-4.2.tar.gz into the same directory
before running make install:
wget https://github.com/TALP-UPC/FreeLing/releases/download/4.2/FreeLing-langs-src-4.2.tar.gz
tar -xzf FreeLing-langs-src-4.2.tar.gz -C FreeLing-4.2/
# Note: extracts into a nested FreeLing-4.2/FreeLing-4.2/data/ — copy up one level:
cp -r FreeLing-4.2/FreeLing-4.2/data/* FreeLing-4.2/data/
Working Catalan config
The default ca.cfg requires an HMM tagger model that is not distributed.
Use the RELAX tagger instead. Create /usr/local/share/freeling/config/ca_working.cfg:
Lang=ca
Locale=ca_ES.UTF-8
TokenizerFile=$FREELINGSHARE/ca/tokenizer.dat
SplitterFile=$FREELINGSHARE/ca/splitter.dat
AffixAnalysis=yes
MultiwordsDetection=yes
NumbersDetection=yes
PunctuationDetection=yes
DatesDetection=yes
QuantitiesDetection=yes
DictionarySearch=yes
DictionaryFile=$FREELINGSHARE/ca/dicc.src
ProbabilityAssignment=yes
ProbabilityFile=$FREELINGSHARE/ca/probabilitats.dat
ProbabilityThreshold=0.001
NERecognition=no
LocutionsFile=$FREELINGSHARE/ca/locucions.dat
QuantitiesFile=$FREELINGSHARE/ca/quantities.dat
AffixFile=$FREELINGSHARE/ca/afixos.dat
PunctuationFile=$FREELINGSHARE/common/punct.dat
Tagger=relax
TaggerRelaxFile=$FREELINGSHARE/ca/constr_gram-B.dat
TaggerRelaxMaxIter=500
TaggerRelaxScaleFactor=670.0
TaggerRelaxEpsilon=0.001
TaggerForceSelect=tagger
DependencyParser=txala
DepTxalaFile=$FREELINGSHARE/ca/dep_txala/dependences.dat
GrammarFile=$FREELINGSHARE/ca/chunker/grammar-chunk.dat
Also build the Catalan dictionary manually (not done by make install on ARM64):
~/FreeLing-4.2/build/src/utilities/build-dict \
~/FreeLing-4.2/data/ca/dictionary/header \
~/FreeLing-4.2/data/ca/dictionary/entries \
> /tmp/ca_dicc.src
sudo mv /tmp/ca_dicc.src /usr/local/share/freeling/ca/dicc.src
Running as a service
Create /etc/systemd/system/freeling.service:
[Unit]
Description=Freeling NLP Server
After=network.target
[Service]
ExecStart=/usr/local/bin/analyzer -f /usr/local/share/freeling/config/ca_working.cfg --server --port 50005
Restart=always
User=YOUR_USERNAME
StandardOutput=append:/var/log/freeling.log
StandardError=append:/var/log/freeling.log
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable freeling
sudo systemctl start freeling
FreeLing 4.2 — Build fixes for ARM64 (Raspberry Pi 5)
Summary
FreeLing 4.2 fails to build from source on ARM64 (tested on Raspberry Pi 5, 8GB,
running Raspberry Pi OS Bookworm 64-bit, GCC 14.2, ICU 76.1). The following fixes
are required. All can be applied before running
cmake.Environment
Fix 1 —
CMakeLists.txt: upgrade C++ standard from 11 to 17ICU 76.x requires C++17. The hardcoded
set(CMAKE_CXX_STANDARD 11)causescompilation to fail with errors like
'is_convertible_v' is not a member of 'std'.File:
CMakeLists.txt, line ~5Fix 2 —
src/libdynet/dynet/mem.cc: remove x86-specific memory functionsmm_malloc.his x86-only and does not exist on ARM64. Replace with standardequivalents.
File:
src/libdynet/dynet/mem.ccFix 3 —
src/libtreeler/treeler/base/scores.h: removeconstfrom mutable memberGCC 14 correctly rejects assignment to a
constmember viaset_score().File:
src/libtreeler/treeler/base/scores.h, line ~85Fix 4 — Missing
#include <cmath>in multiple filesSeveral source files use
log,fabs,sqrtetc. without including<cmath>,which GCC 14 no longer tolerates. Add
#include <cmath>to the top of each:src/include/freeling/morfo/smoothingLD.hsrc/libfreeling/csr_kb.ccsrc/libfreeling/numbers/numbers_cs.ccsrc/libfreeling/output/output_freeling.ccsrc/libfreeling/semdb.ccsrc/libfreeling/maco.ccsrc/libfreeling/hmm_tagger.ccsrc/libfreeling/analyzer_config.ccsrc/libfreeling/accents/accents_gl.ccsrc/libfreeling/analyzer.ccsrc/libfreeling/coref/relaxcor/relaxcor_fex_dep.ccsrc/libfreeling/coref/relaxcor/relaxcor_fex_constit.ccsrc/libfreeling/coref/adaboost/coref_fex.ccsrc/libfreeling/dependency_parsing/dep_lstm.ccsrc/libfreeling/tagset.ccsrc/libfreeling/dates/dates_ru.ccsrc/libfreeling/summarizer/summarizer.ccsrc/libfreeling/omlet/libsvm.ccsrc/libfreeling/omlet/viterbi.ccsrc/libfreeling/ner_module.ccQuick fix using Python:
Fix 5 —
src/libfreeling/analyzer.cc: narrowing conversion ofEOFEOFis-1(signed int) being assigned to an unsigned type, which GCC 14treats as an error in C++17 mode.
File:
src/libfreeling/analyzer.cc, line ~402Fix 6 — Python bindings (
APIs/python3/CMakeLists.txt): enforce C++17The SWIG-generated Python binding code needs C++17 explicitly, as it doesn't
inherit the top-level standard setting.
File:
APIs/python3/CMakeLists.txt— add at end:Build commands (after applying fixes)
Language data
The Catalan language data is not included in
FreeLing-src-4.2.tar.gz.Download and extract
FreeLing-langs-src-4.2.tar.gzinto the same directorybefore running
make install:Working Catalan config
The default
ca.cfgrequires an HMM tagger model that is not distributed.Use the RELAX tagger instead. Create
/usr/local/share/freeling/config/ca_working.cfg:Also build the Catalan dictionary manually (not done by
make installon ARM64):Running as a service
Create
/etc/systemd/system/freeling.service:sudo systemctl daemon-reload sudo systemctl enable freeling sudo systemctl start freeling