фатальная ошибка: cpr / cpr.h: нет такого файла или каталога - PullRequest
0 голосов
/ 05 августа 2020
#include <cpr/cpr.h>
#include <iostream>

int main(int argc, char** argv) {
    cpr::Response r = cpr::Get(cpr::Url{"https://api.github.com/repos/whoshuu/cpr/contributors"},
                      cpr::Authentication{"user", "pass"},
                      cpr::Parameters{{"anon", "true"}, {"key", "value"}});
    r.status_code;                  // 200
    r.header["content-type"];       // application/json; charset=utf-8
    r.text;                         // JSON text string
}

Я хотел запустить это на VScode на ubuntu. Я также добавил в конфигурацию расположение библиотеки CPR.

    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "${default}",
                "${workspaceFolder}/curl/include",
                "${workspaceFolder}/cpr-master/include/"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu18",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

, но я получаю сообщение об ошибке, например

main.cpp:1:10: fatal error: cpr/cpr.h: No such file or directory
    1 | #include <cpr/cpr.h>

Примечание: я не умею добавлять библиотеку C ++, поэтому я спросил этот вопрос. Я также искал это по inte rnet, но я не могу его получить.

Вся командная строка:

enigma@enigma:~/Desktop/test$ g++ main.cpp -o main
main.cpp:1:10: fatal error: cpr/cpr.h: No such file or directory
    1 | #include <cpr/cpr.h>
      |          ^~~~~~~~~~~
compilation terminated.
enigma@enigma:~/Desktop/test$ g++ -I main.cpp -o main
g++: fatal error: no input files
compilation terminated.
enigma@enigma:~/Desktop/test$ 

Моя файловая структура:

enigma@enigma:~/Desktop/test$ ls
cpr-master  curl  json-develop  main.cpp
enigma@enigma:~/Desktop/test$ cd cpr-master
enigma@enigma:~/Desktop/test/cpr-master$ ls
cmake  CMakeLists.txt  CONTRIBUTING.md  cpr  cpr-config.cmake  include  LICENSE  README.md  test
enigma@enigma:~/Desktop/test/cpr-master$ cd include/
enigma@enigma:~/Desktop/test/cpr-master/include$ ls
CMakeLists.txt  cpr
enigma@enigma:~/Desktop/test/cpr-master/include$ cd cpr
enigma@enigma:~/Desktop/test/cpr-master/include/cpr$ ls
api.h   body.h             cookies.h  cprtypes.h    digest.h  limit_rate.h  max_redirects.h  ntlm.h        payload.h  response.h  ssl_options.h   timeout.h      user_agent.h  verbose.h
auth.h  connect_timeout.h  cpr.h      curlholder.h  error.h   low_speed.h   multipart.h      parameters.h  proxies.h  session.h   status_codes.h  unix_socket.h  util.h
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...