ProgrammingSolver
ProgrammingSolver

Reputation: 56

Visual Studio 2022 - Vcpkg can't find an installed package even though it exists

I am using vcpkg, and not using cmake. I am using Visual Studio 2022 and am working on a C project that uses gtk. I installed gtk (x86) successfully, but vcpkg can not find it, even when my project is set to compile to x86.

I already did ".\vcpkg integrate install" both in command prompt and powershell in administrator mode. I already updated vcpkg using git pull and vcpkg update. I already updated visual studio 2022.

In Configuration properties, I have Vcpkg Manifest on, and I tried it with both on and off so it is not the cause of the problem. Also, I tried using installed directory to path to vcpkg's x86-windows install folder before but it did not resolve the issue, so I am leaving the "installed directory" option blank in configuartion property's vcpkg. gtk is a x86 library, I am not using a static library (i have checked), and the project is set to compile to x86.

App.c code: ```

#include <gtk/gtk.h>

int main() {

}
vcpkg.json code:

{
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
  "dependencies": [
    "gtk"
  ]
}

build result:
>  Build started... 1>------ Build started: Project: CGui_TEST, Configuration: Debug Win32 ------ 1>app.c 1>D:\source\repos\CGui_TEST\app.c(1,1): fatal  error C1083: Cannot open include file: 'gtk/gtk.h': No such file or directory 1>Done building project "CGui_TEST.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 8:40 PM and took 00.960 seconds ==========
>

Error List:
> Error    C1083    Cannot open include file: 'gtk/gtk.h': No such file or directory    CGui_TEST   D:\source\repos\CGui_TEST\app.c 1    Error    E1696 cannot open source file "gtk/gtk.h" CGui_TEST   D:\source\repos\CGui_TEST\app.c 1
>

Upvotes: 1

Views: 2320

Answers (1)

radupaul
radupaul

Reputation: 1

I had a similar problem, using vcpkg do integrate "date.h" in a new C++ project.

Setup manifest and the JSON - what I had to do is to run the "build" solution/project twice:

  • the first time is grabbing the vcpkg and dowloads the third-party package: this build ends with the error "Cannot open include file ..."
  • the 2nd build solves the include error.

I tried various pre-link events to avoid running the build twice w/o success.

Upvotes: 0

Related Questions