6

I am trying to build Git from this repository: git-for-windows, which is supposedly last version of git with windows-specific changes. I am working in MinGw32 environment on Windows.

I have run into the following problem: when I try to build git, I get:

compat/mingw.h:134:25: fatal error: openssl/ssl.h: 
No such file or directory  #include <openssl/ssl.h>

Why is that? I have openssl built an installed from source in the same environment, using make -> make install sequence.
In particular, ssl.h was installed into /usr/local/ssl/include/openssl/ssl.h and /local/ssl/include/openssl/ssl.h.

How can I resolve this problem?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Srv19
  • 3,458
  • 6
  • 44
  • 75

6 Answers6

5

Install MSYS2 with MinGW-w64.

Open Mingw64 shell, add the following packages:

$ pacman -Sy mingw64/mingw-w64-x86_64-openssl \
  mingw64/mingw-w64-x86_64-pcre2 \
  mingw64/mingw-w64-x86_64-zlib

Clone and build Git (if you don't have Git yet, you can download a .zip instead)

$ git clone https://github.com/git-for-windows/git.git
$ cd git
$ make
rustyx
  • 80,671
  • 25
  • 200
  • 267
  • This didn't work for me (multiple errors even after adding these packages and others), but the other hand the Git for Windows project now delivers *its own* (MinGW-w64-based) *SDK installer*, which works perfectly, without affecting your existing msys2/mingw-w64 install. – Tao Jun 22 '21 at 13:58
3

The current answer, as of the project website https://gitforwindows.org/#contribute, is to download the "Git for Windows SDK" from that page.

When you execute the installer it clones the SDK, and opens a "Git for Windows SDK" prompt - something very close to an MINGW64 prompt, as far as I can tell.

then:

sdk cd git
sdk build

And you're set, you have a locally-built git.exe! The SDK installs to C:\git-sdk-64 by default, and the git project gets created in C:\git-sdk-64\usr\src\git.

Tao
  • 13,457
  • 7
  • 65
  • 76
1

Since 2015, you can find a more complete example of Windows build through the new ci (continuous integration) folder and its ci/run-windows-build.sh script (March 2017).

It is used in a .travis.yml, meaning you can delegate the actual build to a remote build environment: travis-ci.org/git/git/builds.
That way, you don't have to worry about your own local workstation having or missing dependencies.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The shell script just does `curl https://git-for-windows-ci.azurewebsites.net/api/TestNow` – rustyx Jul 21 '19 at 11:55
  • @rustyx Yes it does. With, as parameter passed to the URL: `?action=trigger&branch=$BRANCH&commit=$COMMIT&skipTests=false`: that is what trigger the *build*. https://github.com/git/git/blob/dcad9a4c87daa4c90d5504e87973d2d5a5d31ff4/ci/run-windows-build.sh#L55 – VonC Jul 21 '19 at 11:58
  • OP asks how to do that locally, not on azure CI. – rustyx Jul 21 '19 at 12:01
  • @rustyx I agree. That is why I proposed this answer as an *alternative*, and concluded with "That way, you don't have to worry about your own local workstation having or missing dependencies.". Hopefully, that might inspire other readers to consider this possibility. – VonC Jul 21 '19 at 12:05
0

Try installing openssl first and then try to build it. Also follow this to get an understanding of your issue(though it is linux specified).

Community
  • 1
  • 1
Abhay Pai
  • 314
  • 4
  • 17
0

Nowadays, it works best with Cygwin. You need to install all the packages it needs or else it will fail the build.

JoelFan
  • 37,465
  • 35
  • 132
  • 205
0

prerequisites:

MSYS2
add to PATH: C:\msys64\usr\bin

pacman -S --needed base-devel mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb mingw-w64-x86_64-curl mingw-w64-x86_64-pcre2

add to PATH: C:\msys64\mingw64\bin


build: (ignore this if building for debugging)

cmd.exe

set MSYSTEM=MINGW64
make

set MSYSTEM=MINGW64 and packages mingw-w64-x86_64-curl mingw-w64-x86_64-pcre2 were what were missing for me


build for debug: https://github.com/git-for-windows/git/wiki/Debugging-Git

create file git/config.mak (git is the repo cloned from https://github.com/git-for-windows/git.git)

DEVELOPER=1
ifndef NDEBUG
CFLAGS := $(filter-out -O2,$(CFLAGS))
ASLR_OPTION := -Wl,--dynamicbase
BASIC_LDFLAGS := $(filter-out $(ASLR_OPTION),$(BASIC_LDFLAGS))
endif

build

set MSYSTEM=MINGW64
make

debug using vscode:

{
  "name": "(gdb) C git",
  "type": "cppdbg",
  "request": "launch",
  "program": "${workspaceFolder}\\git.exe",
  "args": [
    "rev-parse",
    "HEAD",
  ],
  "stopAtEntry": true,
  "cwd": "${workspaceFolder}",
  "environment": [],
  "externalConsole": false,
  "MIMode": "gdb",
  "setupCommands": [
    {
      "description": "Enable pretty-printing for gdb",
      "text": "-enable-pretty-printing",
      "ignoreFailures": true
    }
  ],
}
Mr. Doge
  • 796
  • 5
  • 11