1

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.

RBT
  • 24,161
  • 21
  • 159
  • 240
Robert
  • 11
  • 1
  • 2
    `linker > Additional library` is for a **linker**, you get a compiler error. Looks for the "Additional includes” in the compiler settings. – 273K Apr 30 '23 at 21:17
  • Hi Robert, if the reply is helpful, you could click '✔' to mark my reply as the accepted answer to change its status to Answered. It will also help others to solve the similar issue. – Yujian Yao - MSFT May 11 '23 at 05:54

1 Answers1

-1

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'

Yujian Yao - MSFT
  • 945
  • 1
  • 3
  • 9
  • All necessary details to solve the problem should be in the answer, not behind a link. Websites can be modified or removed and then this answer becomes useless. – jabaa May 01 '23 at 13:05