How to use libgit2 from a native C++ application on Windows? (Microsoft VC++)

后端 未结 2 417
你的背包
你的背包 2020-12-22 07:32

Summary: Is there any tiny example on how to build the Win32 C++ console application that uses the libgit2 library (sources available at GitHub)?

I

相关标签:
2条回答
  • 2020-12-22 07:55

    It's a little surprising if you generated the project from CMake, bit it could be that you're not linking to libgit2.lib. Make sure you have git2.dll in Project Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies.

    link to git2.lib

    0 讨论(0)
  • 2020-12-22 08:12

    This strongly suggests a calling convention mismatch to me. libgit2 uses __stdcall by default, for a number of reasons, while Visual Studio defaults to creating projects that use the __cdecl calling convention. While your program can use either calling convention and successfully call libgit2 using a different one, the easiest solution is probably just to use the same calling convention for both.

    When you configure libgit2, you can turn off the STDCALL flag, which will cause it to emit a library built with __cdecl calling conventions:

    cmake %PATH_TO_LIBGIT2_SOURCE% -DTHREADSAFE=ON -DSTDCALL=OFF
    cmake --build .
    
    0 讨论(0)
提交回复
热议问题