Libgit2 on Windows?

Can anyone provide me with the sequence to successfully build libgit2 on Windows (Win7 pro 64 bit) with Visual Studio 2015? I have tried for the last several weeks and have versions that compile (and lots more that don’t even compile) but when run on Fritzing either can’t update the parts library (on an error in the gitlib2 call) when libssh2 isn’t linked in or when libssh2 and openssl is linked in (which is what works on linux) causes fritzing to “end abnormally” without any indication why and when debugged crashes the Windows debugger without any output. I’m obviously missing something because someone has to have done this but the only things google turns up don’t work for me (and there aren’t that many of them). The only linking version that has libssh2 and openssl in it was from vcpkg for libssh2 and openssl and a manual build of libgit2 because the vcpkg version wants a different (and unspecified) 32 bit libssl2 library, not the one that vcpkg builds (either 64 or 32 bit).


First thing I have to ask is why are you using visual studio when the Fritzing Windows notes say.

Secondly it says.

Which to me implies that VS 2105 may not work at all since it was being built with VS 2008 and VS 2005

The last thing is when I built it on Linux I had to use a very specific version of libgit2 0.23.x

Different things, I am using Qtcreator to run Fritzing, but you need MSC (as opposed to mingw) to compile the libraries, Qtcreator can’t (or at least doesn’t it probably could) compile them, they need to exist before QT can compile Fritzing.

The old rules (QT 5.6 and libgit2 23.4) no longer apply on either platform. On Linux I’m using Qt5.10 (latest stable) and libgit2.0.26.0 (latest stable) which didn’t used to even compile correctly with Fritzing) and it runs fine on Linux, just not Windows so far. So the fix up of the head code to correct the earlier parts problems also fixed the code version issues as a useful side effect (thank you whoever did that!) Libgit2 is apparently a common problem on Windows, there are 3 or 4 versions of how to compile libgit2 on Windows but none of them work for me and as noted the one that compiles then doesn’t work under fritzing with no indication why. I’m hoping someone knows how to get a version of libgit2 that will work with Windows and Fritzing because I sure can’t find one. I have my most annoying problems (corrupt files crashing Fritzing and parts editor not deleting files from the mine parts bin) fixed on the linux system and I want them on the Windows side to see if they cause other problems. To do that I need to be able to build it which I so far can’t (although I don’t seem to be alone in that which does surprise me :slight_smile: ). vcpkg may become a good solution, as it is a Microsoft project to build open source libraries on Windows (that’s where I got versions of libssh2 and openssl for Windows) but the libgit2 it builds doesn’t have libssh2 and doesn’t work with Fritzing although it doesn’t crash, it just gives an error message that it can’t open the git repository (presumably due to the lack of libssh2) and their libssh2 mod uses an unspecified and not included library of some kind (not the libssh2 that it builds). As noted in the thread in wishlist, once I figure this out I’ll add the Windows config to the linux one already posted and post them both here (and maybe someone will contribute a Mac version if we are lucky) so we have a current build guideline with more detail than that on the dev wiki.


1 Like

This is being maddening. The libgit2 problem turns out to be double operator error: I didn’t move all the dlls used in the link in to the libgit2/build64 directory (the tests couldn’t start due to dlls missing was the clue there) then the fritzing-parts repro which I downloaded as a zip file didn’t have the .git directories so it couldn’t find the repro name so I cloned the repro and that looks to work now. With both of those fixed it now dies in populating the database (which it doesn’t on linux) which I’m poking at.

Edit: Well at least I know what is wrong if not why nor how to fix it. In

fritzing-app/src/referencemodel/sqlitereferencemodel.cpp at line 918

else if (path.startsWith(prefix)) {

doesn’t trip because


doesn’t match prefix (the drive letter cases are different)


This is supposed to remove the prefix leaving


but doesn’t apparently because of the different drive letter case which in turn causes the database load to fail for all parts.

Edit2: Perhaps success at last (now to write it all up though :slight_smile: ). No thanks to the Qt docs (it took a stackoverflow post to tell me the Qt::CaseInsensitive )

else if (path.startsWith(prefix, Qt::CaseInsensitive)) {

appears to do a either case compare and cause it to work.
Although I have no idea if this will break things elsewhere than Windows at this point.



Oh perseverance. I commend you good sir! Haven’t run a windows system in years myself. YOU may be their only hope…

I’m not sure there are many windows DEV’s so I’m glad you are documenting what you are doing, should there be others looking to jump in and help.

Have a great weekend!!!

1 Like

I’m not actually planning on developing on Windows (I use Linux for that) but I and I hope other folks need to be able to build the Fritzing head there so fixes can be tested widely. At the moment I’m trying to figure out how Fritzing picks its user directories (I think Qt is doing it internally) with the view to changing the directories from (path)/Friting/ to (path)/Fritzing_dev/ so 0.9.3b and head could co exist on the same machine at the same time. So far I’m unable to figure out where it does this though.

Edit: Success I think. I found the place in src/utils/folderutils.cpp which sets the Fritzing prefix and changing that to Fritzing_dev which so far seems to have redirected the user directories. I’ll try this out for a bit then post a howto on how to do it.



Now you just need to dive into the preferences window and add the ability to set the directory yourself since it is one of the most asked for features.

I’ll look at it, but so far the change is only the the last bit of the path …/Fritzing, the start of the path is set via Qt to whatever is appropriate for the OS involved. Most of the requests I’ve seen are to let Fritzing run on a USB key which I think is more complex than that as it needs a full path (and there are conditions such as writable and app directory) included in the Qt prefix paths.


You could do something like if user provides custom location use custom location else use QT derived location.