Skip to content

Instantly share code, notes, and snippets.

@ThexXTURBOXx
Last active March 19, 2024 09:32
Show Gist options
  • Save ThexXTURBOXx/b75cd2e4721904465718b6c6298333e8 to your computer and use it in GitHub Desktop.
Save ThexXTURBOXx/b75cd2e4721904465718b6c6298333e8 to your computer and use it in GitHub Desktop.
Compiling CoCoALib, CoCoA 5 and C5 Qt-GUI on Windows using CygWin with all external libraries

Instructions

  1. Remove both occurrences of staticlib in lines 7-8 of src/CoCoA-5/QCodeEdit/QCodeEdit.pro.in
  2. Make sure to have some pdflatex distribution installed (works flawlessly with MiKTeX installed on the host machine, not through CygWin)
  3. Install these CygWin packages (newest one should always work fine):
    • cddlib-devel
    • libgmp-devel
    • libgsl-devel
    • libntl-devel
    • libreadline-devel
    • libboost-devel
    • gcc-core
    • gcc-g++
    • cmake
    • make
    • autoconf
    • automake
    • libtool
    • python27-pip
    • libGL-devel
    • libQt5Core-devel
    • libQt5WebKit-devel
  4. Go to /usr/include and create a folder symlink cdd which refers to ./cddlib Also create symlinks for all the files from within the folder ./cddlib in /usr/include itself (Also needed for GFanLib) The last two steps are possible via the following commands (execute them in the working directory <CygWinInstallDir>/usr/include):
    • mklink /D cdd cddlib
    • mklink cdd.h cddlib\cdd.h
    • mklink cdd_f.h cddlib\cdd_f.h
    • mklink cddmp.h cddlib\cddmp.h
    • mklink cddmp_f.h cddlib\cddmp_f.h
    • mklink cddtypes.h cddlib\cddtypes.h
    • mklink cddtypes_f.h cddlib\cddtypes_f.h
    • mklink setoper.h cddlib\setoper.h
    • mklink splitmix64.h cddlib\splitmix64.h
  5. Install txt2tags by downloading https://raw.githubusercontent.com/txt2tags/txt2tags/v2/txt2tags to /usr/local/bin
  6. Download GFanLib (not the normal one, just Gfanlib, e.g. https://math.au.dk/~jensen/software/gfan/gfanlib0.6.2.tar.gz)
  7. Extract the archive
  8. This should result in a folder gfanlib, run cd gfanlib && cp $(ls /usr/share/automake*/mkinstalldirs | head -1) ..
  9. Install it via ./configure && make && make install
  10. Fix the include paths via mkdir /usr/local/include/gfanlib && cp /usr/local/include/gfanlib*.h /usr/local/include/gfanlib/
  11. Download Normaliz (e.g. https://github.com/Normaliz/Normaliz/releases/download/v3.10.2/normaliz-3.10.2.zip)
  12. Install it via autoreconf -i && ./configure --disable-shared --disable-openmp && make && make install
  13. Download Frobby (e.g. https://github.com/Macaulay2/frobby/archive/ae88a0bd93af2d7819db719e51b74eae713d7739.zip)
  14. Install it via cmake . && make && make install
  15. Download MathSAT (optionally, since it does not work for me; does not need to be compiled since it already ships the required binaries, e.g. https://mathsat.fbk.eu/download.php?file=mathsat-5.6.10-win64-msvc.zip)
  16. If you want to include MathSAT, copy all the files from the mathsat-xxx-win64-msvc/bin folder to /usr/local/bin
  17. Now, all libraries should be properly set up and they can be included in CoCoA using the following command (or similar, e.g., without the mathsat part):
    ./configure --with-libcddgmp=/usr/lib/libcddgmp.dll.a --with-libgsl=/usr/lib/libgsl.dll.a --with-libfrobby=/usr/local/lib/libfrobby.a --with-libgfan=/usr/local/lib/libgfan.a --with-libnormaliz=/usr/local/lib/libnormaliz.a --with-libntl --with-libmathsat="/path/to/mathsat-x.x.x-win64-msvc/lib/mathsat.lib"
    

A few notes

  • If you don't need the Qt-GUI (different from the CoCoAInterpreter.exe CLI!), you don't need to install libGL-devel, libQt5Core-devel, and libQt5WebKit-devel and you can disable building it by adding --no-qt-gui to the parameters of the ./configure command of CoCoA
  • If you intend to start the Qt-GUI, you need software capable of hosting a XServer, such as VcXsrv. An easy way to make it start properly then is by using the startx command and then launching C5.exe while your XServer is running on the host machine. For all of that to work, make sure you have CygWin/X properly set up
  • When compiling the Qt-GUI, an additional cygqcodeedit-1.dll is built within src/CoCoA-5/QCodeEdit, which you need in order to start the GUI
  • If you only need CoCoALib as a library, take a look at ECC, which has a few starting points in make_cocoalib.sh and CMakeLists.txt in order to show you how to properly depend on it in CMake
  • ReadLine does not work correctly in the default Windows terminal, only in CygWin. In order for it to work also in other terminals, you need to install the terminfo and possibly the terminfo-extra package within CygWin and add an environment variable which points to the terminfo folder like so: TERMINFO=/cygdrive/x/path/to/terminfo (it is usually within your CygWin installation under /usr/share/terminfo). In this case, x is the drive letter. The path needs to be formatted as a cygpath. Alternatively, you can also download the following archive and unzip it somewhere: terminfo.zip. After that, again add an environment variable which points to the terminfo folder
  • For some reason, when compiling I need to start the CygWin Terminal as an Administrator, because I get "Permission denied" errors otherwise. Maybe, that's just a problem on my system, but still, FYI
  • You can build CoCoA 5 with MATHSAT on Windows successfully, but any commands that include MATHSAT (e.g. MSatLinSolve) do not work correctly (they crash spectacularly). Also, when compiling with MATHSAT, CoCoA depends on Visual C++ Runtime 2013, as reported in #1675
  • The strip command works correctly on the final executable for me and considerably sizes it down
  • To speed up make, a parameter like -j4 speeds up the build significantly by enabling multi-threading
  • In order to run CoCoA in "Vanilla" installations (which don't have the CygWin libraries and binaries), my CoCoA installation looks like this (most DLL files were just copied from /bin):
    .
    ├── CoCoAInterpreter.exe
    ├── CoCoAManual
    │   └── <ManyFilesOmittedHere>
    ├── cygblas-0.dll
    ├── cygboost_filesystem-1_66.dll
    ├── cygboost_system-1_66.dll
    ├── cygcddgmp-0.dll
    ├── cyggcc_s-seh-1.dll
    ├── cyggmp-10.dll
    ├── cyggmpxx-4.dll
    ├── cyggomp-1.dll
    ├── cyggsl-19.dll
    ├── cygncursesw-10.dll
    ├── cygntl-44.dll
    ├── cygreadline7.dll
    ├── cygstdc++-6.dll
    ├── cygwin1.dll
    ├── emacs
    │   ├── cocoa5.el
    │   └── cocoa5.emacs
    ├── MATHSAT.dll (only when you compile with MATHSAT enabled)
    ├── mpir.dll (only when you compile with MATHSAT enabled)
    └── packages
        └── <ManyFilesOmittedHere>
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment