nopnop2002 / esp-idf-smb-client

SMB client example for esp-idf
MIT License
21 stars 8 forks source link

Unable to compile in VSCODE with ESP_IDF extension #6

Open marnikvd opened 2 weeks ago

marnikvd commented 2 weeks ago

Hello,

Title says it all... Is there someone who managed to compile this code in VSCODE with ESP_IDF extension ? some output files CMakeOutput.log idf_py_stderr_output_19976.txt idf_py_stdout_output_19976.txt

I tried also different CMakeLists.txt from here, which brought me a little further, but i couldn't build it.

nopnop2002 commented 2 weeks ago

It looks like the include path is not set correctly.


  CMake Error at
  C:/Users/marnik/esp/mijnProjecten/esp-idf-smb-client/components/libsmb2/CMakeLists.txt:72
  (include):

    include could not find requested file:

Probably the ESP_PLATFORM environment variable is not set. If you add a message to CMakeLists.txt, you may be able to find out what Cmake's behavior is.

message(STATUS  "pass here")
marnikvd commented 2 weeks ago

Hello,

Thank you for the quick response.

I already did the check of ESP_PLATFORM variable before (exactly the way you mention). That was Ok. In the compilation output I can see that this variable is set ...python.exe -DESP_PLATFORM=1 -DCCACHE_ENABLE=1 ... What I find very confusing however, is the way this variable is used in two places in the CMakeLists.txt files in ...\esp-idf-smb-client\components\libsmb2 It says : if(NOT PICO_BOARD OR NOT ESP_PLATFORM) This means that the if block is ALWAYS executed except when you compile for raspberry pi pico AND esp32 at the same time. I think this is NEVER the case. Can you confirm that this is correct? Replacing the OR with AND would make more sense to me. As mentioned in the original post, I also tried completely different CMakeList.txt files, which brought me a little further, but I couldn't build it succesfully.

note : replacing the OR with AND gives this error : CMake Error at C:/Users/marnik/esp/mijnProjecten/esp-idf-smb-client/components/libsmb2/CMakeLists.txt:185 (add_definitions): add_definitions command is not scriptable Call Stack (most recent call first): C:/Users/marnik/esp/v5.2.1/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:107 (include) C:/Users/marnik/esp/v5.2.1/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:127 (component_get_requirements) Call Stack (most recent call first): C:/Users/marnik/esp/v5.2.1/esp-idf/tools/cmake/build.cmake:578 (component_get_requirements) C:/Users/marnik/esp/v5.2.1/esp-idf/tools/cmake/project.cmake:605 (idf_build_process) CMakeLists.txt:8 (project)

nopnop2002 commented 2 weeks ago
 if(NOT PICO_BOARD OR NOT ESP_PLATFORM)

This is the following reversal condition.

 if(PICO_BOARD AND ESP_PLATFORM)

libsmb2 also supports platforms such as Windows, macOS, Xbox, PlayStation. This block is enabled when using these platforms. Please contact the libsmb2 author directly with your questions.

It can be compiled with ESP-IDF's Cmake without any problems.

$ idf.py build
Executing action: all (aliases: build)
Running ninja in directory /home/nop/rtos/esp-idf-smb-client/smb2-ls/build
Executing "ninja all"...
[1/4] cd /home/nop/rtos/esp-idf-smb-client/smb2-ls/build/esp-id...bin /home/nop/rtos/esp-idf-smb-client/smb2-ls/build/smb2-ls.bi
smb2-ls.bin binary size 0xd93e0 bytes. Smallest app partition is 0x100000 bytes. 0x26c20 bytes (15%) free.
[1/1] cd /home/nop/rtos/esp-idf-smb-client/smb2-ls/build/bootlo...rtos/esp-idf-smb-client/smb2-ls/build/bootloader/bootloader.bi
Bootloader binary size 0x6880 bytes. 0x780 bytes (7%) free.
[4/4] Completed 'bootloader'
Project build complete. To flash, run:
 idf.py flash
or
 idf.py -p PORT flash
or
 python -m esptool --chip esp32 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 2MB --flash_freq 40m 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin 0x10000 build/smb2-ls.bin
or from the "/home/nop/rtos/esp-idf-smb-client/smb2-ls/build" directory
 python -m esptool --chip esp32 -b 460800 --before default_reset --after hard_reset write_flash "@flash_args"
marnikvd commented 1 week ago

Following your advice I posted https://github.com/sahlberg/libsmb2/issues/376

sahlberg commented 1 week ago

Do you have instructions how I can set up the ESP_IDF build environment and how I can reproduce this?

Then I can have a look at fixing what broke.

nopnop2002 commented 1 week ago

@sahlberg This problem seems to only occur when using VSCODE extention. I don't use VSCODE extention so I can't reproduce it.

I'm using vanira ESP-IDF. There is nothing wrong with using vanira ESP-IDF.

Thank you for publishing such a wonderful project.

marnikvd commented 1 week ago

Hello,

@nopnop2002 I also tried version ESP-IDF v5.3.1-dirty on the command line (without VSCODE) and I had the same problem.

In the mean time I modified the libsmb2/CMakeLists.txt and deleted libsmb2/lib/CMakeLists.txt to get ESP_IDF working. This took me an awful amount of time since I am not at all familiar with CMake. But now I can compile the project with success on the command line AND in VSCODE. When I get home this evening I will post my libsmb2/CMakeLists.txt

note : I noticed that ESP-IDF v5.3.1-dirty on the command line builds much faster than the version in VSCODE ESP-IDF extension v5.2.1

EDIT : This is my libsmb2/CMakeLists.txt I couldn't make it work with add_subdirectory(lib)