Skip to content

Instantly share code, notes, and snippets.

The Visual Studio compiler generates and modifies many large project-wide binary files during compilation, so normally you can only have one instance of cl running per project. If you use the awesome Ninja tool, it will happily run many instances in parallel on multicore systems. When run this way however, MSVC will throw errors like this:

fatal error C1041: cannot open program database 'sample_project_pathname.pdb';
if multiple CL.EXE write to the same .PDB file, please use /FS
@gavinb
gavinb / Anaconda_Python_OpenCV_fail.md
Last active June 22, 2020 06:03
Solve problem installing OpenCV under Anaconda Python

Using Anaconda's distribution of Python for SciPy on Windows 10

Trying to install OpenCV support according to the official page:

https://anaconda.org/conda-forge/opencv

conda install -c conda-forge opencv

fails with the following error:

@gavinb
gavinb / Build_ITK_app_with_vcpkg.md
Last active October 19, 2020 06:56
How to use ITK with vcpkg

There is a package for the Insight Toolkit (ITK) v5.1 in the vcpkg tool's ports collection. It installs itself into a folder called ITK-5.1 under the triplet's include folder. However, if you are using the Visual Studio integration (which is very convenient) then this will not work. The headers in ITK do not have a prefix, so they expect to be in the root of a specified include path. The solution is to add it manually, thus:

  • go into the Project Properties' dialog
  • go to the 'C/C++ > General' page
  • edit the 'Additional Include Directories' setting
  • add the following entries to the paths:
@gavinb
gavinb / controller.i
Created November 4, 2020 08:17
SWIG example of defining C# property
/*
swig -csharp -c++ -namespace MyControl -outdir ..\gen MyControl.i
*/
%module MyControl
%include <attribute.i>
%{
/* Includes the header in the wrapper code */
@gavinb
gavinb / nvcc_warnings.md
Last active August 1, 2025 13:39
How to disable specific warnings with nvcc

We were seeing the following unexpected warnings in our builds:

C:/BuildAgent/work/19dd4d6ddfbe72aa/SecretProject/vcpkg_installed/x64-windows/include\fmt/format.h(771): warning : base class dllexport/dllimport specification differs from that of the derived class
C:/BuildAgent/work/19dd4d6ddfbe72aa/SecretProject/vcpkg_installed/x64-windows/include\fmt/format.h(3268): warning : base class dllexport/dllimport specification differs from that of the derived class

We use spdlog and fmt all over the place and weren't seeing these warnings elsewhere. Strangely there were not the usual error/warning codes that the compiler emits.
Then I noticed why - these diagnostics were preceded by the module name:

SomeFilter.cu