C++ Can';t包括C+的LIB+;使用cmake+在VS代码中进行项目;vcpkg

C++ Can';t包括C+的LIB+;使用cmake+在VS代码中进行项目;vcpkg,c++,visual-studio-code,cmake,C++,Visual Studio Code,Cmake,我不能包括通过vcpkg安装的第三方库 我正在使用 视窗10 安装了C/C++、CMake和CMake工具插件的Visual Studio代码 获取C++库的VCPKG cygwing++编译器 克马克 我在试着做一些测试项目以供玩弄 我试过: 赖斯蒂尼奥 wxwidgets sqlite3 所有这些都失败了 下面,我将概述我尝试使用sqlite3的情况: 安装: C:\Users\Jaiel>vcpkg install sqlite3 Computing installation

我不能包括通过
vcpkg
安装的第三方库

我正在使用

  • 视窗10
  • 安装了C/C++、CMake和CMake工具插件的Visual Studio代码
  • 获取C++库
  • 的VCPKG
  • cygwing++编译器
  • 克马克
我在试着做一些测试项目以供玩弄

我试过:

  • 赖斯蒂尼奥
  • wxwidgets
  • sqlite3
所有这些都失败了

下面,我将概述我尝试使用sqlite3的情况:

安装

C:\Users\Jaiel>vcpkg install sqlite3
Computing installation plan...
The following packages will be built and installed:
    sqlite3[core]:x86-windows -> 3.35.4#1
Detecting compiler hash for triplet x86-windows...
A suitable version of powershell-core was not found (required v7.1.0). Downloading portable powershell-core v7.1.0...
Downloading powershell-core...
  https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x86.zip -> C:\vcpkg\downloads\PowerShell-7.1.3-win-x86.zip
Extracting powershell-core...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Downloading 7zip...
  https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> C:\vcpkg\downloads\7-zip.commandline.18.1.0.nupkg
Extracting 7zip...
A suitable version of nuget was not found (required v5.5.0). Downloading portable nuget v5.5.0...
Downloading nuget...
  https://dist.nuget.org/win-x86-commandline/v5.5.1/nuget.exe -> C:\vcpkg\downloads\22ea847d-nuget.exe
Using cached binary package: C:\Users\Jaiel\AppData\Local\vcpkg\archives\65\6548fa5df73dbc6b768ef43fa0e5da4ca39334d4.zip
Starting package 1/1: sqlite3:x86-windows
Building package sqlite3[core]:x86-windows...
Building package sqlite3[core]:x86-windows... done
Installing package sqlite3[core]:x86-windows...
Installing package sqlite3[core]:x86-windows... done
Elapsed time for package sqlite3:x86-windows: 27.67 ms

Total elapsed time: 2.061 min

The package sqlite3:x86-windows provides CMake targets:

    find_package(unofficial-sqlite3 CONFIG REQUIRED)
    target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3)


C:\Users\Jaiel>vcpkg integrate install
Applied user-wide integration for this vcpkg root.

All MSBuild C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
教程.cxx

#include <sqlite3.h>
#include <stdio.h>

int main()
{
    printf("%s\n", sqlite3_libversion());
    return 0;
}
CMake输出

# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(test)

find_package(unofficial-sqlite3 CONFIG REQUIRED)

add_executable(test tutorial.cxx)

target_link_libraries(test PRIVATE unofficial::sqlite3::sqlite3)
[main] Building folder: test 
[main] Configuring folder: test 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE:STRING=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\cygwin64\bin\x86_64-pc-cygwin-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\cygwin64\bin\x86_64-pc-cygwin-g++.exe -Hc:/Users/Jaiel/Desktop/test -Bc:/Users/Jaiel/Desktop/test/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:772 (_find_package):
[cmake]   Could not find a package configuration file provided by
[cmake]   "unofficial-sqlite3" with any of the following names:
[cmake] 
[cmake]     unofficial-sqlite3Config.cmake
[cmake]     unofficial-sqlite3-config.cmake
[cmake] 
[cmake]   Add the installation prefix of "unofficial-sqlite3" to CMAKE_PREFIX_PATH or
[cmake]   set "unofficial-sqlite3_DIR" to a directory containing one of the above
[cmake]   files.  If "unofficial-sqlite3" provides a separate development package or
[cmake]   SDK, be sure it has been installed.
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:5 (find_package)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "C:/Users/Jaiel/Desktop/test/build/CMakeFiles/CMakeOutput.log".
它根本不适用于上述三者中的任何一个
wxwidgets
给了我一个不同的错误,即缺少了一些lib和INCLUDE路径,但不管我用谷歌搜索了多少,它都不起作用


有人能帮我吗?

我想是因为vcpkg针对的编译器与您在cmake中使用的编译器不同?我该如何检查这一点?嘿,所以我在cmake缓存文本文件中注意到cmake针对的是x64 windows三元组。我只安装了x86版本。现在,我使用
-triplet=x64 windows
选项再次安装了sqlite3。现在,上述方法确实有效。我想这就是你的意思?
#include <sqlite3.h>
#include <stdio.h>

int main()
{
    printf("%s\n", sqlite3_libversion());
    return 0;
}
# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(test)

find_package(unofficial-sqlite3 CONFIG REQUIRED)

add_executable(test tutorial.cxx)

target_link_libraries(test PRIVATE unofficial::sqlite3::sqlite3)
[main] Building folder: test 
[main] Configuring folder: test 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_TOOLCHAIN_FILE:STRING=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\cygwin64\bin\x86_64-pc-cygwin-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\cygwin64\bin\x86_64-pc-cygwin-g++.exe -Hc:/Users/Jaiel/Desktop/test -Bc:/Users/Jaiel/Desktop/test/build -G "Unix Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:772 (_find_package):
[cmake]   Could not find a package configuration file provided by
[cmake]   "unofficial-sqlite3" with any of the following names:
[cmake] 
[cmake]     unofficial-sqlite3Config.cmake
[cmake]     unofficial-sqlite3-config.cmake
[cmake] 
[cmake]   Add the installation prefix of "unofficial-sqlite3" to CMAKE_PREFIX_PATH or
[cmake]   set "unofficial-sqlite3_DIR" to a directory containing one of the above
[cmake]   files.  If "unofficial-sqlite3" provides a separate development package or
[cmake]   SDK, be sure it has been installed.
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:5 (find_package)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "C:/Users/Jaiel/Desktop/test/build/CMakeFiles/CMakeOutput.log".