esp-idf and emacs with flycheck-mode: esp_log.h: No such file or directory

ruquay
Posts: 2
Joined: Fri Feb 19, 2021 10:28 am

esp-idf and emacs with flycheck-mode: esp_log.h: No such file or directory

Postby ruquay » Fri Feb 19, 2021 10:53 am

My trouble is getting flycheck-mode (in emacs) to properly work for ESP32 development.

For example, if I have

Code: Select all

#include "esp_log.h"
at the top of my file, flycheck-mode reports esp_log.h: No such file or directory. The real problem is that flycheck-mode (at least for c) stops at the first error, and so won't report anything further.

I have tried searching online for this error, and have tried altering the flycheck-clang-include-path variable to include, for example "~/esp/esp-idf/components/log/include" (which, as far as I can tell, is where esp_log.h is located), but the errors remains the same. (This is also the case if I use the absolute path, no symlinks.)

Installing esp-idf, including the export.sh, compiling & flashing all work OK (on the command line inside an emacs shell, in my case). My only problem is getting flycheck-mode to work with this setup.

If there's anyone who knows how to get flycheck-mode working in this development environment, I'd much appreciate your help.

ESP_Angus
Posts: 2280
Joined: Sun May 08, 2016 4:11 am

Re: esp-idf and emacs with flycheck-mode: esp_log.h: No such file or directory

Postby ESP_Angus » Tue Feb 23, 2021 8:42 am

Hi ruquay,

I use emacs for most of my IDF development, but I haven't had much luck with flycheck so far.

It sounds like you've configured flycheck-clang, which means that you'll need the correct include paths but also you may need an LLVM/Clang with ESP32 support for Clang to not produce other errors on things such as inline assemble. Currently this support is not in the upstream LLVM. Overall I'm not sure flycheck-clang is a good fit for flycheck with ESP-IDF, maybe look into the other types of flycheck.

I use rtags for my emacs IDE-like features, which reads the file compile_commands.json that is automatically generated by CMake in the build directory and contains each source file's full compiler command line arguments, header include paths, etc.

rtags works fine for symbol indexing, call graph indexing, etc. In theory flycheck-rtags should work as well (using xtensa-esp32-elf-gcc as the compiler to check the code, rather than Clang). However flycheck-rtags doesn't work in my emacs install, I don't know why (no errors, rtags shows the flycheck install as valid), and I haven't had time to go back and look further!

Sorry I can't actually give you a good solution there, but maybe it gives you some clues for other things to try.

ruquay
Posts: 2
Joined: Fri Feb 19, 2021 10:28 am

Re: esp-idf and emacs with flycheck-mode: esp_log.h: No such file or directory

Postby ruquay » Tue Feb 23, 2021 9:51 am

Hi ESP_Angus, thanks very much for your help, I will look into rtags, I have not used that. In any case I can always just fix up any errors when compiling.

Who is online

Users browsing this forum: Baidu [Spider] and 31 guests