LNK1104(libcurl.lib) не смотря на подключение библиотеки

278
11 февраля 2020, 13:40

Пробовал по разному подключать Curl в основном следовал этому пути, но когда не помогло, то смотрел на этот вариант, что тоже не решило проблему. Постоянно

cannot open file 'libcurl.lib'

Код Main.cpp

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <curl/curl.h>
#include "Data.hpp"

//CurlObj is used to get the html from the given webpage
class CurlObj {
public:
    /**
    * @brief Constructor for a curl object.
    *
    * @param url The url of the page to scrape.
    */
    CurlObj(std::string url) {
        curl = curl_easy_init();
        if (!curl) {
            throw std::string("Curl did not initialize.");
        }
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &CurlObj::curlWriter);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &curlBuffer);
        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
        curl_easy_perform(curl);
    };
    static int curlWriter(char *data, int size, int nmemb, std::string *buffer) {
        int result = 0;
        if (buffer != NULL) {
            buffer->append(data, size * nmemb);
            result = size * nmemb;
        }
        return result;
    }
    std::string getData() {
        return curlBuffer;
    }
protected:
    CURL * curl;
    std::string curlBuffer;
};
//credit to stack overflow for help on the CurlObj class
int main() {
    //the tickers of companies
    std::vector<std::string> names;
    std::string numCompaniesString;
    //get number of companies to research
    std::cout << "Enter the number of companies whose stocks you would like to analyze: ";
    int numCompanies = -1;
    while (numCompanies < 0) {
        try {
            std::cin >> numCompaniesString;
            numCompanies = std::stoi(numCompaniesString);
            if (numCompanies < 0) {
                std::cout << "That is not a valid number. Enter any number greater than 0: ";
            }
        }
        catch (std::exception e) {
            std::cout << "That is not a valid number. Enter any number greater than 0: ";
        }
    }
    //enter the wanted companies' tickers
    for (int i = 0; i < numCompanies; ++i) {
        std::string name;
        std::cout << "Enter the ticker symbol of a company: ";
        std::cin >> name;
        std::transform(name.begin(), name.end(), name.begin(), ::tolower);
        names.push_back(name);
    }
    std::cout << "Please wait for your data. This may take a few seconds." << std::endl << std::endl;
    std::vector<Data> dataObjs;
    //get all the data and print it out
    for (size_t i = 0; i < names.size(); i++) {
        std::string name = names[i];
        std::string address = "https://finance.yahoo.com/quotes/" + name;
        CurlObj temp(address);
        try {
            Data data = Data::Data(name, temp.getData());
            data.printData();
        }
        catch (std::exception e) {
            std::cout << "\n" << name << " is not a valid ticker." << std::endl;
        }
    }
    std::cout << std::endl;
    return 0;
}

Код Data.hpp

#pragma once
#ifndef Data_hpp
#define Data_hpp
#include <stdio.h>
#include <vector>
#include <string>
class Data {
private:
    std::string html;
    std::string sign;
    std::string name;
    double low;
    double high;
    double current;
    double chg;
    double pChg;
public:
    /**
    * @brief Constructor for a Data object.
    *
    * @param NAME The ticker of the company.
    * @param HTML The html to pull info from.
    */
    Data(std::string NAME, std::string HTML);
    /**
    * @brief Picks through the html to find the needed data.
    */
    void fillData();
    /**
    * @brief Prints out all the stock data for a company.
    */
    void printData();
};
#endif /* Data_hpp */

Код Data.cpp

#include "Data.hpp"
#include <vector>
#include <iostream>
Data::Data(std::string NAME, std::string HTML) {
    name = NAME;
    //all the html of the website
    html = HTML;
    fillData();
}
void Data::fillData() {
    std::string changePlace = "yfs_c63_" + name;
    std::string pChangePlace = "yfs_pp0_" + name;
    std::string lowPlace = "yfs_g53_" + name;
    std::string highPlace = "yfs_h53_" + name;
    std::string currentPlace = "yfs_l84_" + name;
    size_t addingSize = changePlace.size() + 2;
    size_t indexChg = html.find(changePlace) + addingSize;
    size_t indexPChg = html.find(pChangePlace) + addingSize;
    size_t indexLow = html.find(lowPlace) + addingSize;
    size_t indexHigh = html.find(highPlace) + addingSize;
    size_t indexCurrent = html.find(currentPlace) + addingSize;
    size_t indexSign = indexChg - 1;
    std::string changeS = html.substr(indexChg + 1, 6);
    std::string pChangeS = html.substr(indexPChg + 1, 6);
    std::string lowS = html.substr(indexLow, 6);
    std::string highS = html.substr(indexHigh, 6);
    std::string currentS = html.substr(indexCurrent, 6);
    sign = html.substr(indexSign + 1, 1);
    chg = std::stod(changeS);
    pChg = std::stod(pChangeS);
    current = std::stod(currentS);
    high = std::stod(highS);
    low = std::stod(lowS);
}
void Data::printData() {
    std::cout << "\n" << name << ":" << std::endl;
    std::cout << "\tCURRENT\t\t" << current << "\n\tLOW\t\t\t" << low <<
        "\n\tHIGH\t\t" << high << "\n\tCHANGE\t\t" << sign << chg <<
        "\n\t%CHANGE\t\t" << sign << pChg << "%" << std::endl;
}
READ ALSO
g++ не видит статическую библиотеку

g++ не видит статическую библиотеку

Доброго времени суток

282
error: no default constructor exists for class

error: no default constructor exists for class

В чём может быть причина такого поведения? Класса SparseMatrix не существует, есть только структура SparseMatrixИспользую Qt Creator 4

244
Как удалять несколько обьектов Range-based цикл

Как удалять несколько обьектов Range-based цикл

Почему происходит ошибка? КомпилЯтор ругается, не могу удалить от начала списка до текущего эллемента? Как исправить?

257