Skip to content

Conversation

tobiasdiez
Copy link
Contributor

On Windows, if you include windows.h then you get the following error

C:/Users/Tobia/.conda/envs/sage-dev/Library/include\flint/qsieve.h(66): error C2059: syntax error: 'type'
C:/Users/Tobia/.conda/envs/sage-dev/Library/include\flint/qsieve.h(69): error C2059: syntax error: '}'

since small is defined as a macro (see eg https://stackoverflow.com/questions/27793470/why-does-small-give-an-error-about-char). To fix this, small is undefined before its used as a variable name.

@albinahlback
Copy link
Collaborator

Good catch!

Co-authored-by: Albin Ahlbäck <[email protected]>
@albinahlback albinahlback merged commit 8ed328a into flintlib:main Oct 27, 2024
@albinahlback
Copy link
Collaborator

Thanks!

@tobiasdiez tobiasdiez deleted the patch-1 branch October 28, 2024 01:21
vbraun pushed a commit to vbraun/sage that referenced this pull request May 17, 2025
sagemathgh-38872: Native Windows build
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

The goal of this PR is to provide a native Windows build of Sage using
MSVC (using the new Meson build system).

Instructions on how to test are under the `Windows` tab at https://doc-
pr-38872--sagemath.netlify.app/html/en/installation/meson.
Afterwards, you should be able to import some sage modules in a normal
`python` install (but most modules actually don't properly import due to
various errors that will be fixed peu a peu in follow-up PRs)

## State of Windows support of dependencies

- m4rie: upstream (https://github.com/malb/m4rie) doesn't provide win
build
- ec: not sure if upstream (https://github.com/JohnCremona/eclib)
provide win build
- ecm: upstream (https://gitlab.inria.fr/zimmerma/ecm) doesn't provide
native win build (only Cygwin)
- ntl: upstream provides win build (kind of), but it's not yet available
on conda (conda-forge/ntl-feedstock#16)
- maxima/ecl: upstream provides win build, but it's not yet available on
conda (conda-forge/maxima-feedstock#38)
- GAP: only cygiwn build exists https://github.com/gap-
system/gap/issues/4157
- [pari](http://pari.math.u-bordeaux.fr/pub/pari): now available on
conda (conda-forge/pari-feedstock#45)
- cypari2: no windows support yet
sagemath/cypari2#19
- lrcalc
- pplpy
- primecountpy
- fpylll
- rw
- cliquer
- lcalc
- ecl
- braiding
- gc
- homfly
- iml
- brial_groebner

## Conda Issues:
- Meson cannot find libraries without pkg-config files.
     - Workaround: Check that `set LIB` includes the conda env (e.g.
`...\.conda\envs\sage-dev\Library\lib`). If not, run `conda deactivate`
followed by `conda activate sage-dev` and then check again.
     - Alternatively, `set LIB=%CONDA_PREFIX%\Library\lib;%LIB%`
     - Possible upstream improvement: the compilers conda package should
set `LIB`
- If you don't have the debug version of Python installed, you may get
"LINK : fatal error LNK1104: cannot open file 'python311_d.lib'"
     - Workaround: `meson setup builddir -Dbuildtype=release`
     - Alternatively, in `<path to conda>\sage-dev\include\pyconfig.h`
uncomment: `//#       define Py_DEBUG` and change `python311_d.lib` to
`python311.lib`
     - Possible upstream improvement: conda should either ship a debug
version of python or a correct `pyconfig.h`
- conda-forge/gsl-feedstock#63
     - Workaround: Fallback to find_library in meson and/or change the
`gsl.pc` to match:
       ```
       prefix=C:/Users/Tobia/.conda/envs/sage-dev/Library
       exec_prefix=C:/Users/Tobia/.conda/envs/sage-dev/Library
       libdir=C:/Users/Tobia/.conda/envs/sage-dev/Library/lib
       sharedlibdir=C:/Users/Tobia/.conda/envs/sage-dev/Library/lib
       includedir=C:/Users/Tobia/.conda/envs/sage-dev/Library/include
       GSL_CBLAS_LIB=-lgslcblas

       Name: GSL
       Description: GNU Scientific Library
       Version: 2.7
       Libs: -L${libdir} -lgsl ${GSL_CBLAS_LIB}
       Cflags: -I${includedir}
       ```
- conda-forge/compilers-feedstock#66
     - Workaround: Run everything in "VS x64 Native Tools Command
Prompt" (for 64bit) or "Developer Command Prompt for VS2022 (or 2019)"
(for 32bit)
- conda-forge/libgd-feedstock#55
     - Workaround: Fallback to find_library in meson
- conda-forge/m4ri-feedstock#15
    - Workaround: Don't try to use m4ri on windows
- conda-forge/libflint-feedstock#38
    - Workaround: Don't try to use flint on windows

## Upstream issues
Singular
- Singular/Singular#1245
- Singular/Singular#1246
- Singular/Singular#1247

Flint:
- flintlib/flint#2100
- mingw-w64/mingw-w64#65 (indirectly since
pthread is flint dependency). Would be fixed by
conda-forge/libflint-feedstock#38.
   -> Workaround: Change `typedef __int64 pid_t;` to `typedef int
pid_t;` in `.conda\envs\sage-dev\Library\include\pthread_compat.h`
- flintlib/flint#2101:
   -> Workaround: disable compilation of fraction_field_FpT for now

Cysignals:
- sagemath/cysignals#207
- sagemath/cysignals#206


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38872
Reported by: Tobias Diez
Reviewer(s): Dima Pasechnik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants