Compile Cython Error: Bits/Libc-Header-Start. H: No Such File or Directory

When compiling a Cython file using following command, I encountered the error 'error while loading shared libraries: libmpfr.so.4'. I link libmpfr.so.4 to libmpfr.so.6 as shown here. After the link, I got the error 'bits/libc-header-start.h: No such file or directory'.

>>>python setup.py build_ext  --inplace

>>>building '_online_lda' extension
gcc -pthread -B /home/rmi/anaconda2/envs/ana36/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/rmi/anaconda2/envs/ana36/lib/python3.6/site-packages/numpy/core/include -I/home/rmi/anaconda2/envs/ana36/include/python3.6m -c _online_lda.c -o build/temp.linux-x86_64-3.6/_online_lda.o
/home/rmi/anaconda2/envs/ana36/libexec/gcc/x86_64-unknown-linux-gnu/4.8.3/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory
error: command 'gcc' failed with exit status 1

What's inside setup.py is

from distutils.core import setup
from Cython.Build import cythonize
import numpy

setup(
    ext_modules = cythonize("_online_lda.pyx"),
    include_dirs = [numpy.get_include()]
)

Then I link libmpfr.so.4 to libmpfr.so.6 using following command.

sudo ln -s /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /usr/lib/x86_64-linux-gnu/libmpfr.so.4

Running the python setup.py again gives following error message.

>>>python setup.py build_ext  --inplace

>>>running build_ext
building '_online_lda' extension
gcc -pthread -B /home/rmi/anaconda2/envs/ana36/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/rmi/anaconda2/envs/ana36/lib/python3.6/site-packages/numpy/core/include -I/home/rmi/anaconda2/envs/ana36/include/python3.6m -c _online_lda.c -o build/temp.linux-x86_64-3.6/_online_lda.o
In file included from /home/rmi/anaconda2/envs/ana36/include/python3.6m/pyport.h:194:0,
                 from /home/rmi/anaconda2/envs/ana36/include/python3.6m/Python.h:53,
                 from _online_lda.c:4:
/usr/include/math.h:27:36: fatal error: bits/libc-header-start.h: No such file or directory
 #include <bits/libc-header-start.h>
                                    ^
compilation terminated.
error: command 'gcc' failed with exit status 1

My Ubuntu version is 18.04.3 LTS. OS type is 64-bit.

1
Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article