FlawlessCalamity
FlawlessCalamity

Reputation: 135

"lwipopts.h: No such file or directory" error when I set up my own project

On my Raspberry Pi Pico W I can run the example blink project just fine. But when I create my own project (even using the same code as the blink project) I cannot get it to work (I know onboard LED is different to that of the standard Raspberry Pi Pico).

I either get everything to compile and when I copy the uf2 file it copies, disconnects and then nothing (no blinking), or I cannot compile after taking snippets from others' CMakeLists.txt files and adding includes in my .c file. Error:

pico-sdk/lib/lwip/src/include/lwip/opt.h:51:10: fatal error: lwipopts.h: No such file or directory
   ----51 | #include "lwipopts.h"

CMakeLists.txt:

cmake_minimum_required(VERSION 3.13)

include(pico_sdk_import.cmake)

project(blink C CXX ASM)
set(CMAKE_C STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

add_executable(blink
    main.c
)

target_include_directories(blink PRIVATE ${CMAKE_CURRENT_LIST_DIR} )

target_link_libraries(blink pico_cyw43_arch pico_stdlib)

pico_add_extra_outputs(blink)

.c file:

#include "pico/stdlib.h"
#include "pico/cyw43_arch.h"

int main() {
    stdio_init_all();
    while (true) {

        printf("LED on\n");
        cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
        sleep_ms(2500);
        printf("LED off\n");
        cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
        sleep_ms(2500);

    }
    return 0;
}

Upvotes: 2

Views: 3123

Answers (2)

dadasign
dadasign

Reputation: 438

I have struggled with this for a while too. I was expecting the file to be some library header, but instead it's a set of option definitions and is included next to sources, not in some sdk folder. In the end I've found the lwipopts.h in particular pico_w example folders, like pico-examples\pico_w\wifi\tcp_server\lwipopts.h. In every case this file actually just links to the \pico-examples\pico_w\wifi\lwipopts_examples_common.h to avoid duplication. Note that the CMakeLists.txt files of the pico_w examples contain:

target_include_directories(picow_tcpip_server_background PRIVATE
        ${CMAKE_CURRENT_LIST_DIR}
        ${CMAKE_CURRENT_LIST_DIR}/.. # for our common lwipopts
        )

in order to include the lwipopts_examples_common.h from the parent directory. You might not need the entry with a reference to the parent directory, unless you also want to follow a folder structure with a lwipopts_examples_common.h one directory above.

Upvotes: 1

vdq
vdq

Reputation: 1

When creating a Pico_W project with the pico-project-generator and selecting the "Polled lwIP" option, then the lwipopts.h is added to the root folder of my project.

However you should also be able to find the missing file in pico-sdk/lib/lwip/src/include/lwip and include this to the CMakeLists.

Upvotes: 0

Related Questions