I'm trying to build SageMath from
source on Ubuntu 20.04. Below is the exact process I tried to follow
(taking notes to be able to pass to other students with little/no linux
experience--like me--so I try to explain each step), but the build
crashed on trying to build gcc-10 with "undefined reference to ZSTD_compress"
and a bunch of other ZSTD-related items. Looking deeper into the config log, it turns out that the gcc's I supplied don't manifest the OpenMC flags ("unknown"), causing it to assume it needs to build it. But when I tested the supplied compilers on a "hello world" .c file using "[gcc-7 | gcc-10] hello.c -fopenmp -o hello", it compiled without error, suggesting it has OpenMC available.
So two questions: why doesn't the below install all needed dependencies for the installer gcc-10 build, and more importantly, why can't ./configure figure out that the compiler I gave it supports OpenMC? Thanks!
Install all the prerecs. Highly recommended ones for better experience are after yasm; optional ones to speed up build time after tk-dev (Note: gcc, g++, and gfortran installed to /usr/bin/):
sudo apt-get install bc binutils bzip2 ca-certificates cliquer cmake curl ecl eclib-tools fflas-ffpack flintqs g++ gcc gfan gfortran glpk-utils gmp-ecm lcalc libatomic-ops-dev libboost-dev libbraiding-dev libbrial-dev libbrial-groebner-dev libbz2-dev libcdd-dev libcdd-tools libcliquer-dev libcurl4-openssl-dev libec-dev libecm-dev libffi-dev libflint-arb-dev libflint-dev libfreetype6-dev libgc-dev libgd-dev libgf2x-dev libgiac-dev libgivaro-dev libglpk-dev libgmp-dev libgsl-dev libhomfly-dev libiml-dev liblfunction-dev liblrcalc-dev liblzma-dev libm4rie-dev libmpc-dev libmpfi-dev libmpfr-dev libncurses5-dev libntl-dev libopenblas-dev libpari-dev libpcre3-dev libplanarity-dev libppl-dev libpython3-dev libreadline-dev librw-dev libsqlite3-dev libssl-dev libsuitesparse-dev libsymmetrica2-dev libz-dev libzmq3-dev libzn-poly-dev m4 make nauty openssl palp pari-doc pari-elldata pari-galdata pari-galpol pari-gp2c pari-seadata patch perl pkg-config planarity ppl-dev python3 python3 python3-distutils r-base-dev r-cran-lattice sqlite3 sympow tachyon tar tox xcas xz-utils yasm gcc-7 g++-7 gfortran-7 dvipng ffmpeg imagemagick texlive texlive-latex-recommended texlive-latex-recommended-doc texlive-fonts-recommended texlive-fonts-recommended-doc texlive-xetex latexmk pandoc default-jdk libavdevice-dev tk tk-dev coinor-cbc coinor-libcbc-dev git graphviz libfile-slurp-perl libigraph-dev libisl-dev libjson-perl libmongodb-perl libnauty-dev libperl-dev libsvg-perl libterm-readkey-perl libterm-readline-gnu-perl libterm-readline-gnu-perl libxml-libxslt-perl libxml-writer-perl libxml2-dev libxml2-dev lrslib ninja-build pari-gp2c
Get the source code:
mkdir ~/Codes
cd ~/Codes
git clone -c core.symlinks=true --branch master https://github.com/sagemath/sage.git
Set up Python environment:
cd ~/Codes/sage
./bootstrap
conda env create -f environment-optional.yml
conda activate sage-pyenv
Build it:
./bootstrap
CC=gcc-7 CXX=g++-7 FC=gfortran-7 ./configure --prefix=$CONDA_PREFIX --with-python=/home/nuker/anaconda3/envs/sage-pyenv/bin/python
This came back with a list of things that will provide extra capability and help build time. I just made sure that those got installed:
conda install arb cddlib curl eclib ecm libflint giac iml lcalc libgd libhomfly openssl pari pari-elldata pari-galdata pari-galpol pari-seadata pari-galdata pari-seadata-small r r-essentials suitesparse xz lrslib pari-nftables
Rerun the ./configure line above (other places suggest ./config.status --recheck && ./config.status, but those would still install a new python-3.9 install, suggesting it lost the --with-python argument).
make
After make, it would crash out with notes about ZSTD when compiling gcc-10.3.0. I tried to add zstd to the conda install line, and get it with apt-get, but neither could be found when compiling gcc-10.3.0 during make (probably because it's isolated to a different path on purpose).
How can I solve the OpenMC flag issue or provide ZSTD for the gcc-10.3.0 build during make? Thanks!
This method will install a new sage python environment that will show up in our anaconda-navigator called sage-pyenv. We should never seen to touch it, but I’d like to be able to see what’s in it.
Set up a simple python environment for it to build into:
Open anaconda-navigator
Create a new environment, call it sage-pyenv, and set it to version 3.8.
Close anaconda-navigator.
We can either use that python environment to install all system prereqs, or do it using system codes. I chose system codes.
Install all the prerecs. Highly recommended ones for better experience are after yasm; optional ones to speed up build time after tk-dev (Note: can’t install with gcc/gfortran 11, the system default, so getting 10):
sudo apt-get install bc binutils bzip2 ca-certificates cliquer cmake curl ecl eclib-tools fflas-ffpack flintqs g++ gcc gfan gfortran glpk-utils gmp-ecm lcalc libatomic-ops-dev libboost-dev libbraiding-dev libbrial-dev libbrial-groebner-dev libbz2-dev libcdd-dev libcdd-tools libcliquer-dev libcurl4-openssl-dev libec-dev libecm-dev libffi-dev libflint-arb-dev libflint-dev libfreetype6-dev libgc-dev libgd-dev libgf2x-dev libgiac-dev libgivaro-dev libglpk-dev libgmp-dev libgsl-dev libhomfly-dev libiml-dev liblfunction-dev liblrcalc-dev liblzma-dev libm4rie-dev libmpc-dev libmpfi-dev libmpfr-dev libncurses5-dev libntl-dev libopenblas-dev libpari-dev libpcre3-dev libplanarity-dev libppl-dev libpython3-dev libreadline-dev librw-dev libsqlite3-dev libssl-dev libsuitesparse-dev libsymmetrica2-dev libz-dev libzmq3-dev libzn-poly-dev m4 make nauty openssl palp pari-doc pari-elldata pari-galdata pari-galpol pari-gp2c pari-seadata patch perl pkg-config planarity ppl-dev python3 python3 python3-distutils r-base-dev r-cran-lattice sqlite3 sympow tachyon tar tox xcas xz-utils yasm gcc-10 g++-10 gfortran-10 dvipng ffmpeg imagemagick texlive texlive-latex-recommended texlive-latex-recommended-doc texlive-fonts-recommended texlive-fonts-recommended-doc texlive-xetex latexmk pandoc default-jdk libavdevice-dev tk tk-dev coinor-cbc coinor-libcbc-dev git graphviz libfile-slurp-perl libigraph-dev libisl-dev libjson-perl libmongodb-perl libnauty-dev libperl-dev libsvg-perl libterm-readkey-perl libterm-readline-gnu-perl libterm-readline-gnu-perl libxml-libxslt-perl libxml-writer-perl libxml2-dev libxml2-dev lrslib ninja-build pari-gp2c
Get the source code:
mkdir ~/Codes
cd ~/Codes
git clone -c core.symlinks=true --branch master https://github.com/sagemath/sage.git
Disable conda, since we don’t need it to do any package management for sage.
conda deactivate
Configure the build environment
cd ~/Codes/sage
./bootstrap
Point it to system gcc-10 and fortran-10 for compilation. It can’t use gcc-11 as of the time of this writing. We also want it to build it’s python stuff in the sage-pyenv environment, so let’s try to do that.
CC=gcc-10 CXX=g++-10 FC=gfortran-10 ./configure --prefix=/home/nuker/Codes/sage/local --with-python=/home/nuker/anaconda3/envs/sage-pyenv/bin/python
This came back with a list of things that will provide extra capability and help build time. I just made sure that those got installed (with optional packages after pari-seadata):
sudo apt-get update
sudo apt-get install libflint-arb-dev libcdd-dev libcdd-tools ecl libec-dev eclib-tools libflint-dev libgiac-dev xcas lcalc liblfunction-dev pari-gp2c libpari-dev pari-doc pari-elldata pari-galdata pari-galpol pari-seadata texlive-latex-extra texlive-xetex latexmk dvipng default-jdk ffmpeg libavdevice-dev pari-gp2c libigraph-dev lrslib
If any were installed (I don’t think it needed to install any more), rerun the ./configure line above (other places suggest ./config.status --recheck && ./config.status, but those didn’t work for me).
Is Conda installing executable / binaries of packages in its environments, not just python packages?
This method will install a new sage python environment that will show up in our anaconda-navigator called sage-pyenv. We should never seen to touch it, but I’d like to be able to see what’s in it.
Set up a simple python environment for it to build into:
Open anaconda-navigator
Create a new environment, call it sage-pyenv, and set it to version 3.8.
Close anaconda-navigator.
We can either use that python environment to install all system prereqs, or do it using system codes. I chose system codes.
Install all the prerecs. Highly recommended ones for better experience are after yasm; optional ones to speed up build time after tk-dev (Note: can’t install with gcc/gfortran 11, the system default, so getting 10):
sudo apt-get install bc binutils bzip2 ca-certificates cliquer cmake curl ecl eclib-tools fflas-ffpack flintqs g++ gcc gfan gfortran glpk-utils gmp-ecm lcalc libatomic-ops-dev libboost-dev libbraiding-dev libbrial-dev libbrial-groebner-dev libbz2-dev libcdd-dev libcdd-tools libcliquer-dev libcurl4-openssl-dev libec-dev libecm-dev libffi-dev libflint-arb-dev libflint-dev libfreetype6-dev libgc-dev libgd-dev libgf2x-dev libgiac-dev libgivaro-dev libglpk-dev libgmp-dev libgsl-dev libhomfly-dev libiml-dev liblfunction-dev liblrcalc-dev liblzma-dev libm4rie-dev libmpc-dev libmpfi-dev libmpfr-dev libncurses5-dev libntl-dev libopenblas-dev libpari-dev libpcre3-dev libplanarity-dev libppl-dev libpython3-dev libreadline-dev librw-dev libsqlite3-dev libssl-dev libsuitesparse-dev libsymmetrica2-dev libz-dev libzmq3-dev libzn-poly-dev m4 make nauty openssl palp pari-doc pari-elldata pari-galdata pari-galpol pari-gp2c pari-seadata patch perl pkg-config planarity ppl-dev python3 python3 python3-distutils r-base-dev r-cran-lattice sqlite3 sympow tachyon tar tox xcas xz-utils yasm gcc-10 g++-10 gfortran-10 dvipng ffmpeg imagemagick texlive texlive-latex-recommended texlive-latex-recommended-doc texlive-fonts-recommended texlive-fonts-recommended-doc texlive-xetex latexmk pandoc default-jdk libavdevice-dev tk tk-dev coinor-cbc coinor-libcbc-dev git graphviz libfile-slurp-perl libigraph-dev libisl-dev libjson-perl libmongodb-perl libnauty-dev libperl-dev libsvg-perl libterm-readkey-perl libterm-readline-gnu-perl libterm-readline-gnu-perl libxml-libxslt-perl libxml-writer-perl libxml2-dev libxml2-dev lrslib ninja-build pari-gp2c
Get the source code:
mkdir ~/Codes
cd ~/Codes
git clone -c core.symlinks=true --branch master https://github.com/sagemath/sage.git
Disable conda, since we don’t need it to do any package management for sage.
conda deactivate
Configure the build environment
cd ~/Codes/sage
./bootstrap
Point it to system gcc-10 and fortran-10 for compilation. It can’t use gcc-11 as of the time of this writing. We also want it to build it’s python stuff in the sage-pyenv environment, so let’s try to do that.
CC=gcc-10 CXX=g++-10 FC=gfortran-10 ./configure --prefix=/home/nuker/Codes/sage/local --with-python=/home/nuker/anaconda3/envs/sage-pyenv/bin/python
This came back with a list of things that will provide extra capability and help build time. I just made sure that those got installed (with optional packages after pari-seadata):
sudo apt-get update
sudo apt-get install libflint-arb-dev libcdd-dev libcdd-tools ecl libec-dev eclib-tools libflint-dev libgiac-dev xcas lcalc liblfunction-dev pari-gp2c libpari-dev pari-doc pari-elldata pari-galdata pari-galpol pari-seadata texlive-latex-extra texlive-xetex latexmk dvipng default-jdk ffmpeg libavdevice-dev pari-gp2c libigraph-dev lrslib
If any were installed (I don’t think it needed to install any more), rerun the ./configure line above (other places suggest ./config.status --recheck && ./config.status, but those didn’t work for me).
Test the build (using parallel processes and omitting tests that take a long time, since we aren’t planning to be doing serious work in Sage). This command left me with a few cython doctest failing and one test failing, with a note that pytest wasn’t installed so wouldn’t be used:
make ptest
Move it to the regular install location per this post:
sudo cp -rl /home/nuker/Codes/sage/local/* /usr/local
sudo cp /home/nuker/Codes/sage/local/man/man1/* /usr/local/man/man1 (because man is already a link, not a directory from some other install)
Finally, install into Jupyter (the install process installed the kernelspec, but it wasn’t working for me)
sudo jupyter kernelspec install /home/nuker/Codes/sage/local/share/jupyter/kernels/sagemath