Trouble compiling using vcpkg and Visual Studio

I am attempting to do the “Visual Studio” build of the KiCad source. I got vcpkg and installed the packages according to the website notes.

I can compile the x64_debug versions of the KiCad elements such as KiCad, EESchema etc using Visual Studio. I can even run the individual programs in debug mode.

I have two problems when I attempt to use the “Install” version of KiCad

  1. The program complains that it is missing DLLs. The DLLs do not seem to have been copied across to the Install directory when the “Install” version of KiCad was built. I manually searched the vcpkg packages and found the relevant DLLs then copied them over into the Install directory and I could then launch the “Install” version of Kicad. Is there some way to modify the settings so that the DLLs are copied across automatically?

  2. KiCad cannot launch subprograms like eeschema from the button menu. It claims that it cannot load the “eeschema.kiface” DLL even though the DLL is in the directory. Looking around the forums, it appears that the DLLs can fail to load if they are missing dependencies. How do I determine these dependencies and again how can I get them to automatically copy across?

EDIT: Using Windows 10 and Visual Studio Community 2019

Thanks

1 Like

You have to make a launch.vs.json to give visual studio launch configuration and tell it PATH to the vcpkg bin. I’ve been meaning to provide a sample in the source tree but :busy:

  1. KiCad cannot launch subprograms like eeschema from the button menu. It claims that it cannot load the “eeschema.kiface” DLL even though the DLL is in the directory. Looking around the forums, it appears that the DLLs can fail to load if they are missing dependencies. How do I determine these dependencies and again how can I get them to automatically copy across?

If working with a debug build. Copy the dlls from vcpkg/installed/x64-windows/debug/bin and not vcpkg/installed/x64-windows/bin

2 Likes

Thanks. This worked for me. I am still looking into the launch.json method.

Hi, I have both problems: 1st one (missing dlls) is solved by copying dlls from vcpkg\installed\x64-windows\debug\bin, but I cannot solve 2nd problem (kiface not found), even when missing kiface files exist in exe (pcbnew.exe) directory. I have followed these instructions: https://dev-docs.kicad.org/en/build/windows-msvc/ (great article), and stuck with exact problems as in this OP.

@marekr, it would be useful if you finish a section about launch.vs.json? :slight_smile: (I cannot find output exe files in solution tree (I probably do not want to add them manually to soulution tree??), as this article states: https://docs.microsoft.com/en-us/visualstudio/ide/customize-build-and-debug-tasks-in-visual-studio?view=vs-2019), or @BoxFish, could you provide more details of how did you managed to run eeschema or pcbnew? For me, kicad.exe starts, but standalones are failing.

Are you just running from the build directory? If so, you’ll want to set KICAD_RUN_FROM_BUILD_DIR in your launch environment.

(I cannot find output exe files in solution tree (I probably do not want to add them manually to soulution tree??), as this article states

You’ll want to read documentation for working with CMake projects, not documentation for working without a project at all. VS2019 has CMake integration and you’ll want to understand how things like CMakeSettings.json and launch.vs.json work. The build outputs should not show up in the solution tree, but you should have launch configurations set up for debugging any of the applications you want to debug.

This is what I did:

  1. Folllow https://dev-docs.kicad.org/en/build/windows-msvc/; Only one thing changed, according to instructions, step 2: { “VcPkgDir”: “D:/vcpkg/” }, changed drive letter to C (as is in my PC);
  2. VS first started, I have opened some cpp file from “Solution Explorer” tree, to keep one of the source file open;
  3. Select “x64-Debug” configuration;
  4. Select startup item “kicad.exe (Install)”;
  5. Click green “build (play)” button;

(“build” button is greyed out here, because building is in progress)

image

Mentioned two issues arose after building is completed (no dll and kiface). Executables are found in kicad\build\install\bin subfolder, if remembered correctly.

Now I am building with additional entry

        {
          "name": "KICAD_RUN_FROM_BUILD_DIR",
          "value": "ON",
          "type": "BOOL"
        },

inside “x64-Debug” section of CMakeSettings.json, is this that you meant to say by:

Are you just running from the build directory? If so, you’ll want to set KICAD_RUN_FROM_BUILD_DIR in your launch environment.

?

There may be some missing steps in instructions, could you update instructions article?

I have successfully used setup as you described here Kicad source compilation with MSVC, but now I decided to upgrade everything…

The instructions are just for building and we don’t yet have instructions for debugging, it would be good to add them.

To set up debugging, go to Debug menu > Debug and Launch Settings for kicad

Inside the configurations list add an entry if one doesn’t exist already, or if it does exist, add your env vars as needed:

{
      "type": "default",
      "project": "CMakeLists.txt",
      "projectTarget": "kicad.exe (kicad\\kicad.exe)",
      "name": "kicad.exe (kicad\\kicad.exe)",
      "env": {
        "KICAD_RUN_FROM_BUILD_DIR": "1"
      }
    }

You can add other env vars to the env section (WXTRACE, etc)

1 Like

Thank you Jon, I failed to launch standalones in professional way… The way that worked for me (eeschema / pcbnew begin to load kiface files) was to copy paste all dlls from kicad nightly installation (C:\Program Files\KiCad\5.99\bin) to \kicad\build\install\x64-Debug\bin or kicad\build\x64-Debug\eeschema folders. Here is a similar thread

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.