sahlberg / libsmb2

SMB2/3 userspace client
Other
325 stars 136 forks source link

error when building for ESP #332

Closed vfirman closed 6 months ago

vfirman commented 6 months ago

Simply clone this project in the 'components' directory of the ESP32 project and it will automatically be included in the build process.

Fresh install of current versions of VSCode(1.88.1) and ESP-IDF extention(1.7.1) New empty project from sample_project template. Cloned this project in the 'components' directory.

Build: ../test4/components/libsmb2/lib/socket.c:109:8: error: redefinition of 'struct linger' 109 | struct linger | ^~ In file included from ../esp/v5.2.1/esp-idf/components/lwip/include/lwip/sockets.h:8, from ../esp/v5.2.1/esp-idf/components/lwip/lwip/src/include/lwip/netdb.h:43, from ../esp/v5.2.1/esp-idf/components/lwip/include/lwip/netdb.h:9, from ../esp/v5.2.1/esp-idf/components/lwip/port/include/netdb.h:14, from ../test4/components/libsmb2/lib/socket.c:27: ../esp/v5.2.1/esp-idf/components/lwip/lwip/src/include/lwip/sockets.h:226:8: note: originally defined here 226 | struct linger { | ^~ [971/978] Building C object esp-idf/libsmb2/CMakeFiles/__idf_libsmb2.dir/lib/usha.c.obj ninja: build stopped: subcommand failed.

And a couple of warnings: [935/978] Building C object esp-idf/libsmb2/CMakeFiles/__idf_libsmb2.dir/lib/init.c.obj ../test4/components/libsmb2/lib/init.c: In function 'smb2_set_password_from_file': ../test4/components/libsmb2/lib/init.c:513:54: warning: this statement may fall through [-Wimplicit-fallthrough=] 513 | buf[strlen(buf) - 1] = 0; | ~~~~~^~~ ../test4/components/libsmb2/lib/init.c:514:25: note: here 514 | default: | ^~~ [941/978] Building C object esp-idf/libsmb2/CMakeFiles/idf_libsmb2.dir/lib/libsmb2.c.obj ../test4/components/libsmb2/lib/libsmb2.c: In function 'smb2_open_async': ../test4/components/libsmb2/lib/libsmb2.c:1189:28: warning: this statement may fall through [-Wimplicit-fallthrough=] 1189 | if ((flags & O_ACCMODE) == O_WRONLY) | ^ ../test4/components/libsmb2/lib/libsmb2.c:1191:17: note: here 1191 | case O_RDONLY: | ^~~~ [968/978] Building C object esp-idf/libsmb2/CMakeFiles/idf_libsmb2.dir/lib/socket.c.obj

sahlberg commented 6 months ago

I can not test ESP builds.

Can you try changing line 108 in lib/socket.c so that is looks like this:

if !defined(HAVE_LINGER) && !defined(_WINDOWS) && !defined(ESP_PLATFORM)

and let me know if this fixes the build?

vfirman commented 6 months ago

it helps (i)Build Successfully

sahlberg commented 6 months ago

Thankyou. I solved it slightly differently and have pushed it to master.

It appears the ESP toolchain/LWIP now provides a definition for linger so I just updated the code to assume linger is present when building on ESP.