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

后端 未结 2 418
你的背包
你的背包 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 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 .
    

提交回复
热议问题