jupyter-xeus / xeus-cling

Jupyter kernel for the C++ programming language
BSD 3-Clause "New" or "Revised" License
3.07k stars 296 forks source link

xeus-cling not work with #include <boost/test/included/unit_test.hpp> but cling do #194

Closed congzhangzh closed 4 years ago

congzhangzh commented 5 years ago

xeus-cling not work with #include <boost/test/included/unit_test.hpp> but cling do

congzhangzh commented 5 years ago

I do test two times, one with pragma like:

========================== xeus-cling with some more search path not work too, like // #pragma cling add_include_path("/home/auser/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/include/c++/7.3.0") // #pragma cling add_include_path("/home/auser/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/x86_64-conda_cos6-linux-gnu") // #pragma cling add_include_path("/home/auser/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/backward")

===================================================== error like(without addition search path by pragma): In file included from input_line_7:1: In file included from /home/auser/miniconda3/envs/cling/include/boost/test/included/unit_test.hpp:18: In file included from /home/auser/miniconda3/envs/cling/include/boost/test/impl/compiler_log_formatter.ipp:22: In file included from /home/auser/miniconda3/envs/cling/include/boost/test/execution_monitor.hpp:28: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/function0.hpp:11: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/detail/maybe_include.hpp:15: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/function_template.hpp:13: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/detail/prologue.hpp:17: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/function_base.hpp:20: In file included from /home/auser/miniconda3/envs/cling/include/boost/integer.hpp:18: In file included from /home/auser/miniconda3/envs/cling/include/boost/integer_fwd.hpp:12: In file included from /usr/include/c++/8/climits:42: In file included from /home/auser/miniconda3/envs/cling/include/limits.h:127: In file included from /home/auser/miniconda3/envs/cling/lib/clang/5.0.0/include/limits.h:37: /usr/include/limits.h:145:5: error: function-like macro '__GLIBC_USE' is not defined

if __GLIBC_USE (IEC_60559_BFP_EXT)

===================================== error like(with addition search path by pragma):

In file included from input_line_8:1: In file included from /home/auser/miniconda3/envs/cling/include/boost/test/included/unit_test.hpp:18: In file included from /home/auser/miniconda3/envs/cling/include/boost/test/impl/compiler_log_formatter.ipp:22: In file included from /home/auser/miniconda3/envs/cling/include/boost/test/execution_monitor.hpp:28: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/function0.hpp:11: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/detail/maybe_include.hpp:15: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/function_template.hpp:13: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/detail/prologue.hpp:17: In file included from /home/auser/miniconda3/envs/cling/include/boost/function/function_base.hpp:20: In file included from /home/auser/miniconda3/envs/cling/include/boost/integer.hpp:18: In file included from /home/auser/miniconda3/envs/cling/include/boost/integer_fwd.hpp:12: In file included from /usr/include/c++/8/climits:42: In file included from /home/auser/miniconda3/envs/cling/include/limits.h:127: In file included from /home/auser/miniconda3/envs/cling/lib/clang/5.0.0/include/limits.h:37: /usr/include/limits.h:145:5: error: function-like macro '__GLIBC_USE' is not defined

if __GLIBC_USE (IEC_60559_BFP_EXT)

^

==================

cling .I output

-cxx-isystem /home/auser/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/include/c++/7.3.0 -cxx-isystem /home/auser/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/x86_64-conda_cos6-linux-gnu -cxx-isystem /home/auser/miniconda3/envs/cling/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/backward -isystem /usr/local/include -isystem /home/auser/work/cling_fun/inst/bin/../lib/clang/5.0.0/include -extern-c-isystem /usr/include/x86_64-linux-gnu -extern-c-isystem /include -extern-c-isystem /usr/include -I /home/auser/work/cling_fun/inst/include -I /home/auser/work/cling_fun/src/tools/cling/include -I . -resource-dir /home/auser/work/cling_fun/inst/bin/../lib/clang/5.0.0 -nostdinc++

========================== xeus-cling .I output

-I /usr/include/c++/8 -I /usr/include/x86_64-linux-gnu/c++/8 -I /usr/include/c++/8/backward -isystem /usr/local/include -isystem /home/auser/miniconda3/envs/cling/lib/clang/5.0.0/include -extern-c-isystem /usr/include/x86_64-linux-gnu -extern-c-isystem /include -extern-c-isystem /usr/include -I /home/auser/miniconda3/envs/cling/include -resource-dir /home/auser/miniconda3/envs/cling/lib/clang/5.0.0 -nostdinc++

================================================================== BTW, I use gxx_linux-64 show by https://www.anaconda.com/blog/developer-blog/utilizing-the-new-compilers-in-anaconda-distribution-5/

saraedum commented 5 years ago

The problem is the include of limits.h. I get

#include <limits.h>
In file included from input_line_8:1:
In file included from /srv/conda/x86_64-conda_cos6-linux-gnu/sysroot/usr/include/limits.h:125:
In file included from /srv/conda/lib/clang/5.0.0/include/limits.h:37:
/usr/include/limits.h:145:5: error: function-like macro '__GLIBC_USE' is not defined
#if __GLIBC_USE (IEC_60559_BFP_EXT)
    ^

This is my environment:

name: root
channels:
  - saraedum
  - conda-forge
  - defaults
dependencies:
  - asn1crypto=0.24.0=py36_1003
  - attrs=18.2.0=py_0
  - backcall=0.1.0=py_0
  - binutils_impl_linux-64=2.31.1=h6176602_1
  - binutils_linux-64=2.31.1=h6176602_3
  - bleach=3.0.2=py_1
  - boost-cpp=1.69.0=h11c811c_1000
  - bzip2=1.0.6=h14c3975_1002
  - ca-certificates=2018.11.29=ha4d7672_0
  - certifi=2018.11.29=py36_1000
  - cffi=1.11.5=py36h5e8e0c9_1
  - chardet=3.0.4=py36_1003
  - clang_variant=1.0=cling
  - clangdev=5.0.0=hdb39e3b_1001
  - cling=0.5=he860b03_1003
  - conda=4.5.12=py36_1000
  - cppzmq=4.3.0=h484f380_1000
  - cryptography=2.3.1=py36hdffb7b8_0
  - cryptography-vectors=2.3.1=py36_1000
  - cryptopp=7.0.0=hf484d3e_1003
  - decorator=4.3.0=py_0
  - defusedxml=0.5.0=py_1
  - entrypoints=0.2.3=py36_1002
  - gcc_impl_linux-64=7.3.0=habb00fd_1
  - gcc_linux-64=7.3.0=h553295d_3
  - gf2x=1.2=ha03fbb7_1003
  - gmp=6.1.2=hfc679d8_0
  - gxx_impl_linux-64=7.3.0=hdf63c60_1
  - gxx_linux-64=7.3.0=h553295d_3
  - icu=58.2=hf484d3e_1000
  - idna=2.8=py36_1000
  - ipykernel=5.1.0=py36h24bf2e0_1001
  - ipython=7.2.0=py36h24bf2e0_1000
  - ipython_genutils=0.2.0=py_1
  - ipywidgets=7.2.1=py36_1
  - jedi=0.13.2=py36_1000
  - jinja2=2.10=py_1
  - jsonschema=3.0.0a3=py36_1000
  - jupyter_client=5.2.4=py_0
  - jupyter_core=4.4.0=py_0
  - jupyterlab=0.34.9=py36_0
  - jupyterlab_launcher=0.13.1=py_2
  - libffi=3.2.1=hfc679d8_5
  - libgcc-ng=7.3.0=hdf63c60_0
  - libiconv=1.15=h14c3975_1004
  - libsodium=1.0.16=h470a237_1
  - libstdcxx-ng=7.3.0=hdf63c60_0
  - libuuid=2.32.1=h14c3975_1000
  - libxml2=2.9.8=h143f9aa_1005
  - llvm-meta=5.0.0=0
  - llvmdev=5.0.0=h6bb024c_1001
  - markupsafe=1.1.0=py36h470a237_0
  - mistune=0.8.4=py36h470a237_0
  - nbconvert=5.4.0=1
  - nbformat=4.4.0=py_1
  - ncurses=6.1=hfc679d8_2
  - nlohmann_json=3.4.0=hf484d3e_0
  - notebook=5.7.4=py36_1000
  - ntl=11.3.1=h501f0de_1001
  - openssl=1.0.2p=h14c3975_1002
  - pandoc=1.19.2=0
  - pandocfilters=1.4.2=py_1
  - parso=0.3.1=py_0
  - pexpect=4.6.0=py36_1000
  - pickleshare=0.7.5=py36_1000
  - pip=18.1=py36_1000
  - prometheus_client=0.5.0=py_0
  - prompt_toolkit=2.0.7=py_0
  - ptyprocess=0.6.0=py36_1000
  - pycosat=0.6.3=py36h470a237_1
  - pycparser=2.19=py_0
  - pygments=2.3.1=py_0
  - pyopenssl=18.0.0=py36_1000
  - pyrsistent=0.14.7=py36h470a237_0
  - pysocks=1.6.8=py36_1002
  - python=3.6.7=h5001a0f_1
  - python-dateutil=2.7.5=py_0
  - pyzmq=17.1.2=py36hae99301_1
  - readline=7.0=haf1bffa_1
  - requests=2.21.0=py36_1000
  - ruamel_yaml=0.15.71=py36h470a237_0
  - send2trash=1.5.0=py_0
  - setuptools=40.6.3=py36_0
  - six=1.12.0=py36_1000
  - sqlite=3.26.0=hb1c47c0_0
  - terminado=0.8.1=py36_1001
  - testpath=0.4.2=py36_1000
  - tk=8.6.9=ha92aebf_0
  - tornado=5.1.1=py36h470a237_0
  - traitlets=4.3.2=py36_1000
  - urllib3=1.24.1=py36_1000
  - wcwidth=0.1.7=py_1
  - webencodings=0.5.1=py_1
  - wheel=0.32.3=py36_0
  - widgetsnbextension=3.2.1=py36_1
  - xeus=0.18.1=h6e680fc_1000
  - xeus-cling=0.4.10=he860b03_1001
  - xtl=0.5.3=h2d50403_0
  - xz=5.2.4=h470a237_1
  - zeromq=4.2.5=hfc679d8_6
  - zlib=1.2.11=h470a237_3
  - conda-env=2.6.0=1
  - libedit=3.1.20170329=h6b74fdf_2
  - yaml=0.1.7=had09818_2
  - libpolygon=0.0.0=1034
  - polygon=0.0.0=master_1034
  - pip:
    - alembic==1.0.5
    - async-generator==1.10
    - jupyterhub==0.9.4
    - mako==1.0.7
    - nteract-on-jupyter==1.9.6
    - pamela==0.3.0
    - python-editor==1.0.3
    - python-oauth2==1.1.0
    - sqlalchemy==1.2.15
prefix: /srv/conda

However, it works if I install xtl=0.5.2. The only difference seems to be the version of zeu-cling, so it's broken with xeus-cling=0.4.10=he860b03_1001 but works with xeus-cling=0.4.10=he860b03_1000.

tadeu commented 5 years ago

I'm having a very similar problem but in a different situation: while trying to #include <eigen3/Eigen/Core>, I'm getting the following error:

In file included from input_line_7:1:
In file included from /srv/conda/include/eigen3/Eigen/Core:286:
In file included from /srv/conda/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/climits:42:
In file included from /srv/conda/x86_64-conda_cos6-linux-gnu/sysroot/usr/include/limits.h:125:
In file included from /srv/conda/lib/clang/5.0.0/include/limits.h:37:
/usr/include/limits.h:145:5: error: function-like macro '__GLIBC_USE' is not defined
#if __GLIBC_USE (IEC_60559_BFP_EXT)

This can be reproduced in the following MyBinder:

https://mybinder.org/v2/gh/ESSS/notebooks/95f146402ff8561940ef63328127a6337a2b2819?filepath=/Eigen%20Broadcasting%20Cheatsheet%20(C%2B%2B).ipynb

Although I could make it work on an Ubuntu 16.04 (with the same environment), it won't work in MyBinder's Ubunty 18.04. In both cases I'm using xeus-cling=0.4.10=he860b03_1001.

Here is the complete !conda list from MyBinder (the only added channel is conda-forge):

alembic                   1.0.5                     <pip>
asn1crypto                0.24.0                py36_1003    conda-forge
async-generator           1.10                      <pip>
attrs                     18.2.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
binutils_impl_linux-64    2.31.1               h6176602_1    conda-forge
binutils_linux-64         2.31.1               h6176602_3    conda-forge
blas                      1.1                    openblas    conda-forge
bleach                    3.0.2                      py_1    conda-forge
blosc                     1.15.1            hf484d3e_1002    conda-forge
bzip2                     1.0.6             h14c3975_1002    conda-forge
ca-certificates           2018.11.29           ha4d7672_0    conda-forge
certifi                   2018.11.29            py36_1000    conda-forge
cffi                      1.11.5           py36h5e8e0c9_1    conda-forge
chardet                   3.0.4                 py36_1003    conda-forge
clang_variant             1.0                       cling    conda-forge
clangdev                  5.0.0             hdb39e3b_1001    conda-forge
cling                     0.5               he860b03_1003    conda-forge
conda                     4.5.12                py36_1000    conda-forge
conda-env                 2.6.0                         1    defaults
cppzmq                    4.3.0             h484f380_1000    conda-forge
cryptography              2.3.1            py36hdffb7b8_0    conda-forge
cryptography-vectors      2.3.1                 py36_1000    conda-forge
cryptopp                  7.0.0             hf484d3e_1003    conda-forge
cycler                    0.10.0                     py_1    conda-forge
dbus                      1.13.0            h4e0c4b3_1000    conda-forge
decorator                 4.3.0                      py_0    conda-forge
defusedxml                0.5.0                      py_1    conda-forge
eigen                     3.3.7             h6bb024c_1000    conda-forge
entrypoints               0.2.3                 py36_1002    conda-forge
expat                     2.2.5             hf484d3e_1002    conda-forge
fastcache                 1.0.2           py36h14c3975_1001    conda-forge
fontconfig                2.12.6                        0    conda-forge
freetype                  2.8.1                hfa320df_1    conda-forge
gcc_impl_linux-64         7.3.0                habb00fd_1    conda-forge
gcc_linux-64              7.3.0                h553295d_3    conda-forge
gettext                   0.19.8.1          h9745a5d_1001    conda-forge
glib                      2.58.2            hf63aee3_1001    conda-forge
gmp                       6.1.2                hfc679d8_0    conda-forge
gmpy2                     2.0.8           py36hb20f59a_1002    conda-forge
gst-plugins-base          1.14.4            hdf3bae2_1001    conda-forge
gstreamer                 1.14.4            h66beb1c_1001    conda-forge
gxx_impl_linux-64         7.3.0                hdf63c60_1    conda-forge
gxx_linux-64              7.3.0                h553295d_3    conda-forge
hdf5                      1.10.4          nompi_h11e915b_1105    conda-forge
icu                       58.2              hf484d3e_1000    conda-forge
idna                      2.8                   py36_1000    conda-forge
ipykernel                 4.8.2                    py36_0    conda-forge
ipython                   6.4.0                    py36_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.2.1                    py36_1    conda-forge
jedi                      0.13.2                py36_1000    conda-forge
jinja2                    2.10                       py_1    conda-forge
jpeg                      9c                h14c3975_1001    conda-forge
jsonschema                3.0.0a3               py36_1000    conda-forge
jupyter_client            5.2.4                      py_0    conda-forge
jupyter_contrib_core      0.3.3                      py_2    conda-forge
jupyter_contrib_nbextensions 0.5.0                 py36_1000    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
jupyter_highlight_selected_word 0.2.0                 py36_1000    conda-forge
jupyter_latex_envs        1.4.4                 py36_1000    conda-forge
jupyter_nbextensions_configurator 0.4.1                    py36_0    conda-forge
jupyterhub                0.9.4                     <pip>
jupyterlab                0.34.9                   py36_0    conda-forge
jupyterlab_launcher       0.13.1                     py_2    conda-forge
kiwisolver                1.0.1           py36h6bb024c_1002    conda-forge
libedit                   3.1.20170329                  0    conda-forge
libffi                    3.2.1                hfc679d8_5    conda-forge
libgcc-ng                 7.3.0                hdf63c60_0    conda-forge
libgfortran-ng            7.2.0                hdf63c60_3    conda-forge
libiconv                  1.15              h14c3975_1004    conda-forge
libpng                    1.6.34               ha92aebf_2    conda-forge
libsodium                 1.0.16               h470a237_1    conda-forge
libstdcxx-ng              7.3.0                hdf63c60_0    conda-forge
libuuid                   2.32.1            h14c3975_1000    conda-forge
libxcb                    1.13              h14c3975_1002    conda-forge
libxml2                   2.9.8             h143f9aa_1005    conda-forge
libxslt                   1.1.32            h4785a14_1002    conda-forge
llvm-meta                 5.0.0                         0    conda-forge
llvmdev                   5.0.0             h6bb024c_1001    conda-forge
lxml                      4.3.0           py36h23eabaa_1000    conda-forge
lzo                       2.10              h14c3975_1000    conda-forge
Mako                      1.0.7                     <pip>
markupsafe                1.1.0            py36h470a237_0    conda-forge
matplotlib                2.2.2                    py36_1    conda-forge
mistune                   0.8.4            py36h470a237_0    conda-forge
mpc                       1.1.0             hb20f59a_1006    conda-forge
mpfr                      4.0.1             ha14ba45_1000    conda-forge
mpmath                    1.1.0                      py_0    conda-forge
nb_conda                  2.2.1                    py36_0    conda-forge
nb_conda_kernels          2.2.0                 py36_1000    conda-forge
nbconvert                 5.4.0                         1    conda-forge
nbformat                  4.4.0                      py_1    conda-forge
ncurses                   5.9                          10    conda-forge
nlohmann_json             3.4.0                hf484d3e_0    conda-forge
notebook                  5.5.0                    py36_0    conda-forge
nteract-on-jupyter        1.9.6                     <pip>
numexpr                   2.6.9           py36h637b7d7_1000    conda-forge
numpy                     1.16.0          py36_blas_openblash1522bff_1000  [blas_openblas]  conda-forge
openblas                  0.3.3             h9ac9557_1001    conda-forge
openssl                   1.0.2p            h14c3975_1002    conda-forge
pamela                    0.3.0                     <pip>
pandas                    0.23.0                   py36_1    conda-forge
pandoc                    1.19.2                        0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.3.1                      py_0    conda-forge
patsy                     0.5.1                      py_0    conda-forge
pcre                      8.41              hf484d3e_1003    conda-forge
pexpect                   4.6.0                 py36_1000    conda-forge
pickleshare               0.7.5                 py36_1000    conda-forge
pip                       18.1                  py36_1000    conda-forge
prometheus_client         0.5.0                      py_0    conda-forge
prompt_toolkit            1.0.15                     py_1    conda-forge
pthread-stubs             0.4               h14c3975_1001    conda-forge
ptyprocess                0.6.0                 py36_1000    conda-forge
pycosat                   0.6.3            py36h470a237_1    conda-forge
pycparser                 2.19                       py_0    conda-forge
pygments                  2.3.1                      py_0    conda-forge
pyopenssl                 18.0.0                py36_1000    conda-forge
pyparsing                 2.3.1                      py_0    conda-forge
pyqt                      5.6.0           py36h13b7fb3_1008    conda-forge
pyrsistent                0.14.7           py36h470a237_0    conda-forge
pysocks                   1.6.8                 py36_1002    conda-forge
pytables                  3.4.4           py36h5d69a80_1004    conda-forge

python                    3.6.5                         1    conda-forge
python-dateutil           2.7.5                      py_0    conda-forge
python-editor             1.0.3                     <pip>
python-oauth2             1.1.0                     <pip>
pytz                      2018.9                     py_0    conda-forge
pyyaml                    3.13            py36h14c3975_1001    conda-forge
pyzmq                     17.1.2           py36hae99301_1    conda-forge
qt                        5.6.2                         7    conda-forge
readline                  7.0                           0    conda-forge
requests                  2.21.0                py36_1000    conda-forge
ruamel_yaml               0.15.71          py36h470a237_0    conda-forge
scipy                     1.1.0           py36_blas_openblash1522bff_1202  [blas_openblas]  conda-forge
seaborn                   0.9.0                      py_0    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                40.6.3                   py36_0    conda-forge
simplegeneric             0.8.1                      py_1    conda-forge
sip                       4.18.1          py36hf484d3e_1000    conda-forge
six                       1.12.0                py36_1000    conda-forge
SQLAlchemy                1.2.15                    <pip>
sqlite                    3.20.1                        2    conda-forge
statsmodels               0.9.0           py36h3010b51_1000    conda-forge
sympy                     1.1.1                    py36_0    conda-forge
terminado                 0.8.1                 py36_1001    conda-forge
testpath                  0.4.2                 py36_1000    conda-forge
tk                        8.6.9                ha92aebf_0    conda-forge
tornado                   5.1.1            py36h470a237_0    conda-forge
traitlets                 4.3.2                 py36_1000    conda-forge
urllib3                   1.24.1                py36_1000    conda-forge
wcwidth                   0.1.7                      py_1    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.32.3                   py36_0    conda-forge
widgetsnbextension        3.2.1                    py36_1    conda-forge
xeus                      0.18.1            h6e680fc_1000    conda-forge
xeus-cling                0.4.10            he860b03_1001    conda-forge
xorg-libxau               1.0.8             h14c3975_1006    conda-forge
xorg-libxdmcp             1.1.2             h14c3975_1007    conda-forge
xtl                       0.5.3                h2d50403_0    conda-forge
xz                        5.2.4                h470a237_1    conda-forge
yaml                      0.1.7                had09818_2    defaults
zeromq                    4.2.5                hfc679d8_6    conda-forge
zlib                      1.2.11               h470a237_3    conda-forge
tadeu commented 4 years ago

Seems fixed to me as of 0.4.11

qlibp commented 1 year ago

Have the sam problem, but not quite understand the root reason. cling version is 0.9, and installed via miniconda when trying to include ros.h.

Already specify the include path: /usr/include /usr/include/x86_64-linux-gnu

jonas-eschmann commented 1 year ago

Same as @qlibp but when including hdf5.h. In a plain cling interpreter it works like a charm but in xeus-cling it leads to this issue