Open kuznero opened 9 years ago
@kuznero I'm sorry, but I've never tried it, so I have no better information at this point than you do. I think you might have better luck trying to build from the official libgit2 tarball. Then, if you can get that to build, you can port the changes back over into hlibgit2's cabal file.
Is there any way to compile
hlibgit2
on Windows?
I have just compiled it on Windows.
include-dirs:
libgit2/src/win32
E:\Distr\openssl-3.0.0-win64-mingw\include
E:\Distr\Regex\include
extra-lib-dirs:
E:\Distr\Regex\lib
E:\Distr\openssl-3.0.0-win64-mingw\lib64
Then I tried to build with cabal:
S C:\Projects\Haskell\gitlib\hlibgit2> cabal build
Build profile: -w ghc-9.2.5 -O1
In order, the following will be built (use -v for more details):
- hlibgit2-0.18.0.16 (lib) (first run)
- hlibgit2-0.18.0.16 (test:smoke) (first run)
Preprocessing library for hlibgit2-0.18.0.16..
Building library for hlibgit2-0.18.0.16..
In file included from libgit2\src\common.h:30,
from libgit2\src\fetch.c:13:0: error:
libgit2\src\win32\mingw-compat.h:13:0: error: warning: "lseek" redefined 13 | # define lseek _lseeki64 |
---|---|
13 | # define lseek _lseeki64 |
^ |
In file included from E:/HSP/ghcup/ghc/9.2.5/mingw/x86_64-w64-mingw32/include/sys/stat.h:14, from libgit2\src\common.h:21,
from libgit2\src\fetch.c:13:0: error:
E:\HSP\ghcup\ghc\9.2.5\mingw\x86_64-w64-mingw32\include\io.h:352:0: error: note: this is the location of the previous definition 352 | #define lseek lseek64 |
---|---|
352 | #define lseek lseek64 |
^ |
In file included from libgit2\src\common.h:30,
from libgit2\src\fetch.c:13:0: error:
libgit2\src\win32\mingw-compat.h:14:0: error: warning: "stat" redefined 14 | # define stat _stati64 |
---|---|
14 | # define stat _stati64 |
^ |
In file included from libgit2\src\common.h:21,
from libgit2\src\fetch.c:13:0: error:
E:\HSP\ghcup\ghc\9.2.5\mingw\x86_64-w64-mingw32\include\sys\stat.h:279:0: error: note: this is the location of the previous definition 279 | #define stat _stat64 |
---|---|
279 | #define stat _stat64 |
^ |
In file included from libgit2\src\common.h:30,
from libgit2\src\fetch.c:13:0: error:
libgit2\src\win32\mingw-compat.h:15:0: error: warning: "fstat" redefined 15 | # define fstat _fstati64 |
---|---|
15 | # define fstat _fstati64 |
^ |
In file included from libgit2\src\common.h:21,
from libgit2\src\fetch.c:13:0: error:
E:\HSP\ghcup\ghc\9.2.5\mingw\x86_64-w64-mingw32\include\sys\stat.h:280:0: error: note: this is the location of the previous definition 280 | #define fstat _fstat64 |
---|---|
280 | #define fstat _fstat64 |
^ |
In file included from libgit2\src\hash/hash_win32.h:15, from libgit2\src\hash.h:24, from libgit2\src\filebuf.h:11, from libgit2\src\index.h:11, from libgit2\src\repository.h:16, from libgit2\src\remote.h:14,
from libgit2\src\fetch.c:14:0: error:
E:\Distr\openssl-3.0.0-win64-mingw\include\openssl\bio.h:867:29: error: error: expected ')' before ';' token 867 | int (gets) (BIO , char *, int)); | ^~~~ |
---|---|---|
867 | int (gets) (BIO , char *, int)); | |
^ |
gcc.exe' failed in phase
C Compiler'. (Exit code: 1)
cabal-3.6.2.0.exe: Failed to build hlibgit2-0.18.0.16 (which is required by
test:smoke from hlibgit2-0.18.0.16).
As you can see build unsuccessful
6. Then I try change build command to
``` bash
&"E:\HSP\ghcup\bin\ghc.exe" "--make" "-fbuilding-cabal-package" "-O" "-outputdir" "C:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build" "-odir" "C:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build" "-hidir" "C:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build" "-stubdir" "C:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build" "-i" "-iC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build" "-i." "-iC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\autogen" "-iC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\global-autogen" "-IC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\autogen" "-IC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\global-autogen" "-IC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build" "-Ilibgit2/include" "-Ilibgit2/src" "-Ilibgit2/deps/http-parser" "-Ilibgit2/src/win32" "-IC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\libgit2/include" "-IC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\libgit2/src" "-IC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\libgit2/deps/http-parser" "-IC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\libgit2/src/win32" "-IE:\Distr\openssl-3.0.0-win64-mingw\include" "-IE:\Distr\Regex\include" "-optP-DWINDOWS" "-optP-include" "-optPC:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\build\autogen\cabal_macros.h" "-this-unit-id" "hlibgit2-0.18.0.16-inplace" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "E:\HSP\cabal\store\ghc-9.2.5\package.db" "-package-db" "C:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\packagedb\ghc-9.2.5" "-package-db" "C:\Projects\Haskell\gitlib\hlibgit2\dist-newstyle\build\x86_64-windows\ghc-9.2.5\hlibgit2-0.18.0.16\package.conf.inplace" "-package-id" "base-4.16.4.0" "-package-id" "bindings-DSL-1.0.25-d8a29754a88ed46c0fc731c63bca65bc5212dbfb" "-package-id" "zlib-0.6.3.0-a86c87747cd334b31145fa89d5013e7318d2ca69" "-XHaskell98" "-XForeignFunctionInterface" "Bindings.Libgit2" "Bindings.Libgit2.Attr" "Bindings.Libgit2.Blob" "Bindings.Libgit2.Branch" "Bindings.Libgit2.Checkout" "Bindings.Libgit2.Clone" "Bindings.Libgit2.Commit" "Bindings.Libgit2.Common" "Bindings.Libgit2.Config" "Bindings.Libgit2.CredHelpers" "Bindings.Libgit2.Diff" "Bindings.Libgit2.Errors" "Bindings.Libgit2.Graph" "Bindings.Libgit2.Ignore" "Bindings.Libgit2.Index" "Bindings.Libgit2.Indexer" "Bindings.Libgit2.Merge" "Bindings.Libgit2.Message"
"Bindings.Libgit2.Net" "Bindings.Libgit2.Notes" "Bindings.Libgit2.Object" "Bindings.Libgit2.Odb" "Bindings.Libgit2.OdbBackend" "Bindings.Libgit2.Oid" "Bindings.Libgit2.Pack" "Bindings.Libgit2.Push" "Bindings.Libgit2.Refdb" "Bindings.Libgit2.RefdbBackend" "Bindings.Libgit2.Reflog" "Bindings.Libgit2.Refs" "Bindings.Libgit2.Refspec" "Bindings.Libgit2.Remote" "Bindings.Libgit2.Repository" "Bindings.Libgit2.Reset" "Bindings.Libgit2.Revparse" "Bindings.Libgit2.Revwalk" "Bindings.Libgit2.Signature" "Bindings.Libgit2.Stash" "Bindings.Libgit2.Status" "Bindings.Libgit2.Strarray" "Bindings.Libgit2.Submodule" "Bindings.Libgit2.Tag" "Bindings.Libgit2.Threads" "Bindings.Libgit2.Trace" "Bindings.Libgit2.Transport" "Bindings.Libgit2.Tree" "Bindings.Libgit2.Types" "Bindings.Libgit2.Version" "Bindings.Libgit2.Windows" "-Wall" "-hide-all-packages"
Such command generated by cabal during cabal build
, but important: I deleted flag: "-IE:\HSP\ghcup\msys64\mingw64\include" and after that build was successful. Does anyone else know how to disable it in *.cabal file?
Building hlibgit2 on Windows
Trying to fix it by modifying
Bindings/Libgit2/Windows.hsc
and adding missing (thoughWindows.hsc
seams to be auto-generated by the ruby script) reference to common module:This time it goes further up until C code:
At this point I got desperate and removed
Bindings.Libgit2.Windows
module from cabal project completely (from cabal file andBindings.Libgit2
module) as I thought that manipulating codepages might not be most important thing I will need going forward (I'm sure, that I'm wrong on this in the long run though). This is what I got:Is there any way to compile
hlibgit2
on Windows?