Setting up Windows dev & build environment
(1) By matt w. (maphew) on 2023-02-28 05:33:56 [link] [source]
Anyone have advice on how they set up and use their Windows computers to develop and compile Fossil that supplement or goes beyond the bit in section 2.8.d of downloading and compiling fossil?
My story thus far: I installed cmake via
winget install Microsoft.VisualStudio.2022.BuildTools
followed by Start >> Visual Studio installer >> and Select 'Desktop development with C++' kit and it's ~7 GB download.
I know the config is valid because installing the Rust package stork-search which requires compiling works (ref).
I'm using VS-Code for my IDE and have installed the extensions:
- C/C++ and C/C++ Extension Pack
- Cmake and Cmake Tools
In vscode, on opening a Fossil file such as src/branch.c
(from fossil clone https://fossil-scm.org
) Cmake configure runs and appears happy; No errors reported, though there is a deprecation warning (full output text).
However Intellisense is giving me a warning that #include config.h
has a problem because 'cannot open source file "unistd.h"'. After some exploring I see there is a file by that name under ./win/includes
whose header says it is to be a drop in replacement for this unix system file.
This being a strong signal I've not yet set up vscode appropriately I also followed the bare bones instructions from the official Fossil doc, section 2.8.d. This path too is not happy yet:
CMD C:\Users\mhwilkie\code\fossil-scm\win
» nmake /f Makefile.msc
Microsoft (R) Program Maintenance Utility Version 14.34.31937.0
Copyright (C) Microsoft Corporation. All rights reserved.
Building zlib from "..\compat\zlib"...
Microsoft (R) Program Maintenance Utility Version 14.34.31937.0
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1073: don't know how to make './zconf.h'
Stop.
NMAKE : fatal error U1077: 'pushd' : return code '0x2'
Stop.
CMD C:\Users\mhwilkie\code\fossil-scm\win
» buildmsvc.bat
Microsoft (R) Program Maintenance Utility Version 14.34.31937.0
Copyright (C) Microsoft Corporation. All rights reserved.
Building zlib from "C:\Users\mhwilkie\code\fossil-scm\win\..\compat\zlib"...
Microsoft (R) Program Maintenance Utility Version 14.34.31937.0
Copyright (C) Microsoft Corporation. All rights reserved.
NMAKE : fatal error U1073: don't know how to make './zconf.h'
Stop.
NMAKE : fatal error U1077: 'pushd' : return code '0x2'
Stop.
Build failure, errors were encountered.
Suggestions?
(2) By Warren Young (wyoung) on 2023-02-28 06:08:43 in reply to 1 [link] [source]
Anyone have advice on how they set up and use their Windows computers to develop and compile Fossil
Sensible people begin with installing WSL, Cygwin, or a Linux VM… 😛
install Microsoft.VisualStudio.2022.BuildTools…~7 GB download.
…for this reason and others…
I'm somewhat kidding, but realize you could've had a whole other OS with that space investment, the kind where the term "OS" implicitly includes compilers, development libraries, capable code editors, and more.
Cmake configure runs and appears happy
Why are you bringing CMake into this? Fossil has no infrastructure for building using CMake.
#include config.h has a problem because 'cannot open source file "unistd.h"'.
That one should be guarded by #ifndef (_WIN32)
.
Likely you're seeing a practical result of my quasi-teasing above: as I recall, the Windows binaries are built under MinGW on a Linux box, so the pure-Windows case doesn't get tested as often as you might guess.
If you want to appoint yourself the pure-Windows czar, I doubt you'll get a lot of people fighting you for the position.
don't know how to make './zconf.h'
That file should be in your tree already:
$ fossil finfo compat/zlib/zconf.h
History for compat/zlib/zconf.h
2023-01-24 [76fa165763] …
(3) By Daniel Dumitriu (danield) on 2023-02-28 12:47:45 in reply to 1 [link] [source]
While I somehow tend to agree with Warren in that development is easier on Linux (I also do that - at least for cross-platform testing - on Debian/Ubuntu and FreeBSD), and that the Visual Studio/C++ part is ridiculously and needlessly large, development on Windows is possible and necessary.
The document on the Fossil build process is a good read before going on - on any platform - and also shows how to build OpenSSL.
If you do not need an IDE, you can use the recipes here, for which nmake
and cl
suffice.
Otherwise: I use VS Code myself with the two C/C++ extensions that you mentioned installed - no CMake needed as the Fossil project has not (yet) any setup for that. I have the following terminal entry added to settings.json
:
"terminal.integrated.profiles.windows": {
"DevCmd": {
"path": "C:\\WINDOWS\\System32\\cmd.exe",
"args": ["/k", "C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Auxiliary\\Build\\VcVarsAll.bat", "amd64"]
}
}
When starting that terminal in VS Code, I see the following:
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.5.0
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
N:\dev\fossil\trunk>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32215 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
If you want SSL support (probably you do), be sure to follow the Fossil doc you'd already mentioned about how to build that on Windows. (The OpenSSL build takes a lot of space, after that you can remove everything except for \include
, libssl.lib
, and libcrypto.lib
.)
Then, say
N:\dev\fossil\trunk> win\buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_ENABLE_JSON=1 clean fossil.exe
and you should be good to go - the json and clean parts are optional, of course. You can jump to the lines causing warnings/errors by clicking on them in the terminal, and code navigation works for the most part as expected - it has sometimes problems with the header files, but on the whole the experience is good. Pay attention that what gets compiled in the end are the *_.c
files - the differences are not great but still.
(4) By matt w. (maphew) on 2023-03-01 04:06:10 in reply to 2 [link] [source]
Sensible people begin with installing WSL, Cygwin, or a Linux VM… 😛
For better and worse I live in Windows Land ;-) I did spend a few weeks with WSL a few months ago (elapsed time, not concentrated). I eventually gave up on it for fossil related work because Windows does something weird with virtual networking and I just couldn't figure out a relialbe path through. Which I suppose is just another argument for switching OS! But I'm embedded in too many things which keep me here, for now anyway.
'./zconf.h' ... file should be in your tree already
Yep, it's there, so something in the environment still needs setting. Daniel has provided some things to try. I'm on that next.
(5.2) By Warren Young (wyoung) on 2023-03-01 22:01:33 edited from 5.1 in reply to 4 [link] [source]
Windows does something weird with virtual networking
It's not Windows proper, it's the WSL2 container model, where it creates a separate IP scheme inside the container. I don't know if it's full NAT or simply subnet routing, but yes, it does create something of a PITA.
There are ways around this, but I wasn't actually suggesting converting entirely to Linux. I believe I'm one of the most ecumenical people regularly here on this forum, so my path is to "yes-and" all the things. Rather than Windows or Linux, I want Windows and Linux and macOS and FreeBSD and even OS/8 where that makes sense… :)
Use the right tool for the job. In this instance, Windows has a rotten CLI, even after you put PowerShell in the whizzy new Windows Terminal. I'd even take ksh93 plus a contemporaneous version of xterm over that pairing. That's how far ahead Unix CLI/scripting is compared to Windows. It's why WSL exists in the first place: Microsoft has conceded the fight, having come to the realization that despite their billions, they aren't going to catch up now.
I'm making two Fossil-relevant points here:
Fossil's primary build environment is heavily dependent on those Unix scripting technologies, primarily POSIX shell and Tcl. Other build systems don't get as much attention, so you'll encounter occasional breakages like the above incorrect
#include <unistd.h>
on Windows case. You can either appoint yourself the latest one in charge of fixing all this — you're welcome to it! — or you can follow the low-friction path into a Unixy build environment, if only for cross-compilation.I wasn't suggesting using WSL2 as a Fossil server, but merely that you install WSL2 as a Windows cross-compilation environment, so you can use the same MinGW tooling that drh uses when building the official native Windows binaries. This path we know works, all the time, yes?
That yields a plain old PE format
fossil.exe
file which you can then run directly from the WSL2 volume or copy it out to/mnt/c/somewhere
to run for real.
EDIT: Clarity pass only.
(6) By matt w. (maphew) on 2023-03-02 04:34:05 in reply to 4 [source]
'./zconf.h' ... file should be in your tree already
Yep, it's there ...
I was mistaken, it was not there.
» fossil status
repository: C:/Users/mhwilkie/code/fossil-scm.fossil
local-root: C:/Users/mhwilkie/code/fossil-scm/
config-db: C:/Users/mhwilkie/AppData/Local/_fossil
checkout: 9eadac2026626b7153b7816981245d3d4335397f 2023-02-27 12:31:56 UTC
parent: 7cd1ebd093a47d2d2ffdb0ce5b9ac4159b86f9b1 2023-02-27 12:25:09 UTC
child: 4717db33f0033b48f7fd74194b203c02df0f8195 2023-02-28 05:41:53 UTC
tags: trunk
comment: Make similar improvements to the documentation for /zip and /sqlar. (user: drh)
MISSING ../compat/zlib/zconf.h
A round of fossil sync
and fossil update
restored it, after which nmake stopped complaining and I successfully built a fossil.exe using win\buildmsvc.bat
Running nmake directly while enabling openssl fails, but I'll troubleshoot that for awhile before making any kind of report here. (Compiling openssl itself worked fine.)
(7) By Richard Hipp (drh) on 2023-03-02 12:29:09 in reply to 6 [link] [source]
Have you seen the Release Build How-To wiki page on the main Fossil repository? It explains how I build the precompiled Fossil binaries that go on the Download page. Maybe this will provide more hints on how to build for your platform?
(8) By matt w. (maphew) on 2023-03-03 04:12:16 in reply to 7 [link] [source]
Yes, thank you. It turns out the remaining thing needed to successfully build with openssl was to rename compat/openssl-3.0.8
to bare openssl
so that the includes worked.
Now I can work on remembering what my original goal was before going down this learning path!
(9) By matt w. (maphew) on 2023-03-03 04:22:19 in reply to 5.2 [link] [source]
I like that, yes-and all the things.
I didn't know WSL could compile exe's that can work in the host outside the container. I would have taken that path! My previous reading on cross compilation gave me the idea that it was complicated. Admittedly that was some time ago.