-
Notifications
You must be signed in to change notification settings - Fork 893
How to build x64 libgit2 and LibGit2Sharp
Also see: https://github.com/libgit2/libgit2/blob/master/README.md
- Visual Studio 2010 SP1 with VC++
- CMake 2.8.5
- git version 1.7.5.1 (cygwin 1.7.9)
- 64-Bit Visual C++ Toolset (also available as part of the Windows SDK)
> git clone git://github.com/libgit2/libgit2.git
Start the Visual Studio 2010 x64 Win64 Command Prompt.
Add the path to the CMake binaries to the PATH environment variable:
> set PATH=c:\path\to\your\cmake2.8\bin;%PATH%
Currently, building libgit2 against VS2010 x64 raises lots of warnings which makes the build fail. Indeed, libgit2 is not LLP64 compliant (see this Wikipedia article for further information about specific C language models).
An issue has been raised in order to deal with this topic. Meanwhile, as a workaround, one can change /WX
compiler option into /WX-
in order to instruct the linker not to consider warnings as errors.
$ git diff CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7655e0b..e2cf729 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,7 +55,7 @@ IF (MSVC)
# Not using __stdcall with the CRT causes problems
OPTION (STDCALL "Buildl libgit2 with the __stdcall convention" ON)
- SET(CMAKE_C_FLAGS "/W4 /nologo /Zi ${CMAKE_C_FLAGS}")
+ SET(CMAKE_C_FLAGS "/W4 /wd4244 /wd4267 /nologo /Zi ${CMAKE_C_FLAGS}")
IF (STDCALL)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
ENDIF ()
> cd libgit2
> mkdir buildx64
> cd buildx64
> cmake -G "Visual Studio 10 Win64" ..
-- Check for working C compiler using: Visual Studio 10 Win64
-- Check for working C compiler using: Visual Studio 10 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: path/to/your/libgit2/buildx64
> cmake --build .
Warnings C4244 and C4267 will be raised... and ignored thanks to the patching/hacking of the CMakeLists.txt.
Change project target from x86 to AnyCPU
$ git diff LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
index ddf10df..8ed5884 100644
--- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
+++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
@@ -21,7 +21,7 @@
<DefineConstants>TRACE;DEBUG;NET35</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <PlatformTarget>x86</PlatformTarget>
+ <PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
$ git diff LibGit2Sharp/LibGit2Sharp.csproj
diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj
index e38804e..060bd99 100644
--- a/LibGit2Sharp/LibGit2Sharp.csproj
+++ b/LibGit2Sharp/LibGit2Sharp.csproj
@@ -24,7 +24,7 @@
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <PlatformTarget>x86</PlatformTarget>
+ <PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
415 passed, 0 failed, 1 skipped