PQXX/PQXX:在VS代码中没有此类文件或目录GCC,我使用VCPKG

问题描述 投票:0回答:0
我尝试配置C_CPP_PROPERTIES.JSON

{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**", "C:\\Users\\takuya\\vcpkg\\installed\\x64-windows\\include" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "windowsSdkVersion": "10.0.22621.0", "compilerPath": "C:\\msys64\\ucrt64\\bin\\g++.exe", "cStandard": "c17", "cppStandard": "c++20" } ], "version": 4 } 不管我有多么努力地指定包含的路径,GCC发誓还是发誓。

main.cpp文件代码:

#include <iostream> #include <pqxx/pqxx> // fatal error: pqxx/pqxx: No such file or directory using namespace std; using namespace pqxx; int main() { try { connection conn("host=localhost port=5432 dbname=testdb user=postgres password=564789s"); if (conn.is_open()) { cout << "Connected to database successfully!" << endl; } else { cerr << "Failed to connect to database." << endl; } } catch (const exception &e) { cerr << "Error: " << e.what() << endl; return 1; } return 0; }
Cmakelists.txt

make_minimum_required(VERSION 3.10) project(MyProject) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake" CACHE STRING "") find_package(libpqxx CONFIG REQUIRED) add_executable(main main.cpp) target_link_libraries(main PRIVATE libpqxx::pqxx)

eRror:

C:\Users\takuya\Desktop\test\build>C:\msys64\ucrt64\bin\g++.exe -DPQXX_SHARED @CMakeFiles/main.dir/includes_CXX.rsp -g -std=c++20 -o CMakeFiles\main.dir\main.cpp.obj -c C:\Users\takuya\Desktop\test\main.cpp
C:\Users\takuya\Desktop\test\main.cpp:2:10: fatal error: pqxx/pqxx: No such file or directory
    2 | #include <pqxx/pqxx>
      |          ^~~~~~~~~~~
compilation terminated.

即使没有PQXX的动态加载,所有功能都可以正常工作,显然问题是在破裂的W10上安装了通常的问题,一切都可以很好地工作。对不起,浪费了时间。感谢您的帮助!
    

c++ gcc vcpkg
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.