wiringPi.h library not found, getting a build error

431 views Asked by At

My code is throwing an error sayiung it can't find wiringPi.h. I thought that setting project > configuration properties > linker > Additional library directories to the place the header is contained would work. However, I still get this error:

Error cannot find wiringPi: No such file or directory Agresso C:\usr\bin\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;
}


Any thoughts? I am using windows subsystem for Linux.

I tried to link wiringPi.h via project configuration properties.

Program should compile.

1

There are 1 answers

1
Yujian Yao - MSFT On

It looks like you are using visual studio to link the dll, I suggest you refer to the steps in this document.

In addition, this issue is also worth your reference.

For you still trying to achieve this, Merlyn Oppenheim, from visual studio, set up a sample project using VS 2019 and Raspberry PI template -> https://github.com/merlynoppenheim/sample-rasp-inc-headers

For this sample project the Visual Studio properties page should have:

C/C++ -> General -> Additional Include Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/include;%(AdditionalIncludeDirectories)'

C/C++ -> Linker -> General -> Additional Library Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/debug/lib;%(AdditionalLibraryDirectories)'

C/C++ -> Linker -> Input -> Library Dependencies = 'wiringPi;sqlite3;pthread;dl'