PlatfomIO cannot find a cpp file

Hello,
I think there is a problem with my paths. I am including HardwareSerial.h for an arduino project, but platformIO doesn’t manage to build because it cannot find the corresponding cpp files. It looks in the following directory:

`

/home/antonio/OpenSourceCelluloid/software/platformIO/PCB-NANO/home/antonio/.platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial0.cpp

`

PCB-NANO is the directory where my project is, but for some reason it goes back to home (/home/antonio) and starts looking for the packages. How can I fix this?

What’s your platformio.ini and code?

1 Like

This is my .ini:

PlatformIO Project Configuration File

Build options: build flags, source filter
Upload options: custom upload port, speed and extra flags
Library options: dependencies, extra library storages
Advanced options: extra scripting

Please visit documentation for the other options and examples
https://docs.platformio.org/page/projectconf.html

[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
monitor_speed = 115200

Do you need to see the header, the .cpp or the main.cpp? It could get too long if I post all three.

Could you upload the (cleaned) project to github or zip on like GoogleDrive?

Thank you very much for your help, here is the github link:

I can build the firmware fine (though I have to remove 3 libraries in pcb-nano/lib at master · acastles91/pcb-nano · GitHub to which you forgot to include as a submodule / file and do it via lib_deps):

 pio run
Processing nanoatmega328 (platform: atmelavr; board: nanoatmega328; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/nanoatmega328.html
PLATFORM: Atmel AVR 1.15.0 > Arduino Nano ATmega328
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 30KB Flash
PACKAGES: toolchain-atmelavr 1.50400.190710 (5.4.0), framework-arduinoavr 4.1.2
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Looking for TMCStepper library in registry
Found: https://platformio.org/lib/show/5513/TMCStepper
LibraryManager: Installing id=5513
Using cache: /home/max/.platformio/.cache/f2/c964ba3bc2d0f713c5f18c28dffcb7f2
TMCStepper @ 0.5.2 has been successfully installed!
Looking for TimerOne library in registry
Found: https://platformio.org/lib/show/131/TimerOne
LibraryManager: Installing id=131
TimerOne @ 1.1 has been successfully installed!
Found 9 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <TMCStepper> 0.5.2
|   |-- <SPI> 1.0
|   |-- <SoftwareSerial> 1.0
|-- <TimerOne>
|-- <AccelStepper>
|-- <SPI> 1.0
Building in release mode
[...]
DATA:    [==        ]  20.7% (used 424 bytes from 2048 bytes)
PROGRAM: [===       ]  34.4% (used 10574 bytes from 30720 bytes)
================ [SUCCESS] Took 5.82 seconds ================

In a PIO terminal, what is the output of pio --version?

Also 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.

Thank you max, and sorry for the inconvenience with submodules, I still don’t know how to use them since I’m still very new with git and programming.

My pio --version is:
PlatformIO, version 4.1.0

The .log is here:

The path looks OK and they are not concatenated.

/home/antonio/.platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial0.cpp: In function 'void __vector_18()':
/home/antonio/.platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial0.cpp:49:5: error: 'Serial' was not declared in this scope
     Serial._rx_complete_irq();
     ^
/home/antonio/.platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial0.cpp: In function 'void __vector_19()':
/home/antonio/.platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial0.cpp:64:3: error: 'Serial' was not declared in this scope
   Serial._tx_udr_empty_irq();
   ^

Still this error in the framework makes no sense. The definition of Serial is in HardwareSerial.h which is included.

Please remove the folder /home/antonio/.platformio/packages/framework-arduinoavr completely, then retry compilation.

1 Like

It’s compiling now, thanks! No idea why it was looking for the files somewhere else.

1 Like