10/11/2016 – Installing Caffe on Windows using the Microsoft port

Documenting Caffe installation on Windows for steps that may seem too obvious for other users.

    1. Download zip Caffe githubs to some directory
    2. Follow instructions on the github site
    3. Additional steps
    4. Once built, add the libcaffe project to your own project, you need to right click on the libcaffe project (not your own!) in visual studio and add the Additional headers that is found in the include directory. Looks something like $(ProjectDir)..\..\include

. Also add $(ProjectDir)..\..\include\proto if it asks for the caffe.pb.h file.

  • The Nuget directory should be 2 levels up from the caffe windows directory
  • If you get an error about a mismatch of platform, go to Build->Configuration manager and just select Win32 or x64 for all of them. Uncheck the option for creating new solution platforms if you get something saying that the solution already exists.
  • Make sure everything is using the same build platform. All dlls and libraries should be either 32 bit (x86) or 64 bit. All dependencies in your solution have to match as well.
  • If there is a mismatch for the runtime library, make sure that for the libcaffe project, the Project Properties->C/C++->Code Generation Runtime Library option matches the rest of your solution
  • I get a leveldb error even though I include the LevelDb.lib file provided by the nuget package. I got a leveldb debug lib file from here. Im using a win32 application with MDD
  • Next, for building in debug mode, add the dlls from the nuget packages. Make sure that you get the correct architecture. If you are building a win32 application choose the binaries and libraries from the win32 folders. Otherwise if you are building a 64 bit application choose from the x64 folder.
  • Everything should build successfully. If you get a 0xc000007b error, it means that your dlls are of a different type from the application type you are trying to build. I.e 32 bit dlls for a 64 bit project or vice versa.
  • If still having trouble, Get the Dependency walker and point it to the exe file of your project after it builds. It should tell you which dlls are missing and also if the dlls are of the wrong platform.


  • When actually running your application with Caffe, you have to include the header paths of all the Nuget packages into your solution via Properties->C/C++->General.
  • If you’re running CPU, you might get an error about a cublas header. Just put #define CPU_ONLY at the top of the file where the error is found.
  • If you get an error ‘C2059: syntax error: ‘constant” in your caffe.pb.h file, try adding
    ifdef STRICT
    undef STRICT
    To your caffe.pb.h file