wiringPi.h 库未找到,生成错误

问题描述 投票:0回答:1

我的代码抛出一个错误,说找不到 wiringPi.h。我认为设置项目 > 配置属性 > 链接器 > 包含标头的位置的其他库目录会起作用。但是,我仍然收到此错误:

Error cannot find wiringPi: No such file 或者 目录 Agresso C:\usr in\ld 1

#include <iostream>
#include <cmath>
#include <wiringPi.h>

const int thermistorPin = 0; // thermistor is connected to GPIO 0
const int B = 3950;          // B value of thermistor
const int R0 = 10000;        // R0 = 10kOhm
const int R_LIMIT = 100000;  // maximum value for R

double readTemperature()
{
    int a = analogRead(thermistorPin);
    double R = R_LIMIT * a / (1023 - a);
    double T = 1 / (log(R / R0) / B + 1 / 298.15) - 273.15;
    return T;
}

int main(void)
{
    if (wiringPiSetup() == -1)
        return 1;

    while (true)
    {
        double temperature = readTemperature();
        std::cout << "Temperature: " << temperature << " C" << std::endl;
        delay(1000);
    }
    return 0;
}


有什么想法吗?我正在为 Linux 使用 Windows 子系统。

我试图通过项目配置属性链接wiringPi.h

程序应该编译。

c++ visual-studio cross-platform wiringpi
1个回答
-1
投票

看起来你是用visual studio链接dll,我建议你参考这个文档中的步骤。

另外,这个issue也值得大家参考

© www.soinside.com 2019 - 2024. All rights reserved.