HDK
HDK

Reputation: 1

Cannot open source file "mosquitto.h"C/C++(1696)

I am trying to include mosquitto.h into my project. I installed mosquitto from "mosquitto-2.0.18-install-windows-x64" installer to C:\Program Files\mosquitto\devel. It seems like I have to add that address to somewhere but I dont have any clear idea where to. When i build the program, i got this error:

[build] D:\RP_Pico_W_mqtt_test\RP_Pico_W_2_mqtt\main2.c:3:10: fatal error: mosquitto.h: No such file or directory
[build]     3 | #include <mosquitto.h>
[build]       |          ^~~~~~~~~~~~~
[build] compilation terminated.
[build] mingw32-make[2]: *** [CMakeFiles\main2.dir\build.make:75: CMakeFiles/main2.dir/main2.c.obj] Error 1
[build] mingw32-make[1]: *** [CMakeFiles\Makefile2:1509: CMakeFiles/main2.dir/all] Error 2
[build] mingw32-make: *** [Makefile:90: all] Error 2

And I wrote a simple code with raspberry pi pico w:

#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"
#include <mosquitto.h>

int main() 
{
    stdio_init_all();
    if (cyw43_arch_init()) 
    {
        printf("Wi-Fi init failed");
        return -1;
    }
    while (true) 
    {

    }
    return 0;
}

I am new to all these Cmake, VScode and Pico w. Please help me!

Upvotes: 0

Views: 185

Answers (1)

Rain Zhou
Rain Zhou

Reputation: 21

u need to add -I"C:\Program Files\mosquitto\devel" parameters to your compile command.

Upvotes: 0

Related Questions