Error while Linking in VS PlatformIO

This is an esp32 wroom project I have compiled numerous time successfully in VS PlatformIO. But now I can’t build. I was always getting some warning messages but nothing as an error about:
JSON:

class ARDUINOJSON_DEPRECATED("use JsonDocument instead") StaticJsonDocument

SPI:

#warning "INFO: ARDUINO SPI interface selected."

However now when Linking the firmware I get the following error:

...
...
Compiling .pio/build/esp32doit-devkit-v1/FrameworkArduino/wiring_shift.c.o
Archiving .pio/build/esp32doit-devkit-v1/libFrameworkArduino.a
Indexing .pio/build/esp32doit-devkit-v1/libFrameworkArduino.a
Linking .pio/build/esp32doit-devkit-v1/firmware.elf
/home/mickey/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -l/home/mickey/Documents/PlatformIO/Projects/myproject/=
/home/mickey/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -l/home/mickey/Documents/PlatformIO/Projects/myproject/1
/home/mickey/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -l/home/mickey/Documents/PlatformIO/Projects/myproject/=
/home/mickey/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -l/home/mickey/Documents/PlatformIO/Projects/myproject/1
collect2: error: ld returned 1 exit status
*** [.pio/build/esp32doit-devkit-v1/firmware.elf] Error 1

in my ini I have tried the following:

lib_extra_dirs = /home/mickey/Documents/PlatformIO/Projects/myproject/.pio/build/esp32doit-devkit-v1

with no luck. What am I doing wrong? Any building options? Is it a path thing I am missing? Thank you

Using Windows as OS? If yes path length limit is the issue. Place your project when possible at c:\myproject to shorten path

I am in ubuntu linux

Please show the full platformio.ini

Here is the full platformio.ini :slight_smile:

[env:esp32doit-devkit-v1]
platform = espressif32
;board = esp32doit-devkit-v1
board = esp32dev
framework = arduino

board_build.flash_size = 8MB
board_build.partitions = Partition_Table_8mb.csv
build_flags = 
	-DDEBUG_MODE = 1 
	-DVERSION = 1

board_upload.flash_size = 8MB
board_upload.maximum_size = 8388608
board_upload.wait_for_upload_port = yes
board_upload.use_1200bps_touch = yes

monitor_port = Auto
monitor_speed = 115200
monitor_filters = colorize
monitor_echo = yes
;this might not be necessary and in any case too long??
lib_extra_dirs = /home/mickey/Documents/PlatformIO/Projects/esp32wroomproject/.pio/build/esp32doit-devkit-v1

lib_deps = 
	ESP Async WebServer
	https://github.com/bblanchon/ArduinoJson
	https://github.com/knolleary/pubsubclient@2.8
	adafruit/Adafruit Unified Sensor @ ^1.1.9
	adafruit/Adafruit BusIO @ ^1.14.1
	adafruit/Adafruit NeoPixel@^1.12.3
	adafruit/Adafruit BME280 Library@^2.2.4
	adafruit/Adafruit BMP280 Library@^2.6.8
	majicdesigns/MD_MAX72XX@^3.5.1
	majicdesigns/MD_Parola@^3.7.3

[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
build_flags = 
	-DARDUINO_USB_MODE=0
	-DARDUINO_USB_CDC_ON_BOOT=1
	-DBOARD_HAS_PSRAM
	-DDEBUG_MODE=1 
	-DVERSION=2

board_build.flash_size = 4MB
board_build.partitions = Partition_Table.csv
board_build.mcu = esp32s3

debug_tool = esp-builtin

board_upload.flash_size = 4MB
board_upload.wait_for_upload_port = yes
board_upload.use_1200bps_touch = yes
;upload_port = /dev/ttyACM0
monitor_port = Auto
monitor_speed = 115200
monitor_filters = colorize
monitor_echo = yes

lib_deps = 
	ESP Async WebServer
	https://github.com/bblanchon/ArduinoJson
	https://github.com/knolleary/pubsubclient@2.8
	adafruit/Adafruit Unified Sensor @ ^1.1.9
	adafruit/Adafruit BusIO @ ^1.14.1
	adafruit/Adafruit NeoPixel@^1.12.3
	adafruit/Adafruit BME280 Library@^2.2.4
	adafruit/Adafruit BMP280 Library@^2.6.8
	majicdesigns/MD_MAX72XX@^3.5.1
	majicdesigns/MD_Parola@^3.7.3

This is very unspecific. Better add details which library and version should be used:

esp32async/ESPAsyncWebServer @ ^3.7.4

lib_extra_dirs” is deprecated and should be replaced by symlink. Please see lib_extra_dirs — PlatformIO latest documentation and change this to symlinks.

Ok, I followed your recommendations, deleted the .pio directory as I saw elsewhere, rebuild it, but I still I get :frowning:

Building in release mode
Linking .pio/build/esp32doit-devkit-v1/firmware.elf
/home/mickey/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -l/home/mickey/Documents/PlatformIO/Projects/esp32wroomproject/=
/home/mickey/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -l/home/mickey/Documents/PlatformIO/Projects/esp32wroomproject/1
/home/mickey/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -l/home/mickey/Documents/PlatformIO/Projects/esp32wroomproject/=
/home/mickey/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: cannot find -l/home/mickey/Documents/PlatformIO/Projects/esp32wroomproject/1
collect2: error: ld returned 1 exit status
*** [.pio/build/esp32doit-devkit-v1/firmware.elf] Error 1

It can’t find
/home/mickey/Documents/PlatformIO/Projects/esp32wroomproject
during link. The project is in the Workspace.

Please execute

pio run -t clean
pio run -v > compile.log 2>&1

and upload the resulting compile.log to pastebin.com and post the link here.

The log file gets pretty big, 3124576 characters, pastebin allows me to paste 512kb per paste. Would you like to paste just the errors or break it in parts? Sorry for the inconvenience.
I have included the start and finish of each environment, I hope this can help https://pastebin.com/CXU3RFM2

Can you share the whole project?

Should these messages just before ld returned 1 exit status direct us to think that there is something wrong with path or platformio installation setup? There are some warning messages about SPI as I said earlier

#warning "INFO: ARDUINO SPI interface selected."

and I have relocated the project directory to /home/Projects/ , I did all the Misc. check and verbose builds and the error persists.

It’s hard to debug (find the cause of this error) without having the code.

Can you share your project, please?

I have found the problem!! It was hidden in plain sight !! In platformio.ini (see above) there are the lines that describe the build flags. The correct syntax is without spaces in between!! Like so:

build_flags = 
	-DDEBUG_MODE=1 
	-DVERSION=1

The linking somehow was messed up when spaces were present.

Linking .pio/build/esp32doit-devkit-v1/firmware.elf
Retrieving maximum program size .pio/build/esp32doit-devkit-v1/firmware.elf
Checking size .pio/build/esp32doit-devkit-v1/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  15.1% (used 49424 bytes from 327680 bytes)
Flash: [===       ]  29.6% (used 987933 bytes from 3342336 bytes)
Building .pio/build/esp32doit-devkit-v1/firmware.bin
esptool.py v4.5.1
Creating esp32 image...
Merged 27 ELF sections
Successfully created esp32 image.
==================================================================== [SUCCESS] Took 48.02 seconds ====================================================================

The bottom line:
-DDEBUG_MODE = 1 :x: (breaks things)
-DDEBUG_MODE=1 :white_check_mark: (all good)