local libraries and include dependencies
See original GitHub issueConfiguration
Atom 1.40.1 x64 PlatformIO 2.2.0 Core 4.0.2 GNU/Linux Debian Streach x64 (9)
Description of problem
Dependency error compiling code when not include custom lib in main code. Including myclim.h is optional.
I tried to compile this code in Arduino IDE, and have no error, including or not myclim.h in main.cpp. In this case, DHT.h is always compiled in Arduino IDE, even if myclim.h is not included in main.cpp.
Steps to Reproduce
- Compile code with #include <myclim.h> in main.cpp (not error when compiling)
- Compile code without #include <myclim.h> in main.cpp (error when compiling)
Actual Results
If myclim.h is included in main code, it is compiled without errors. But, if I remove the line #include <myclim.h> in main.cpp, I get the follow error:
Processing pro16MHzatmega328 (platform: atmelavr; board: pro16MHzatmega328; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/pro16MHzatmega328.html
PLATFORM: Atmel AVR > Arduino Pro or Pro Mini ATmega328 (5V, 16 MHz)
HARDWARE: ATMEGA328P 16MHz 2KB RAM (30KB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 17 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <mylib>
Compiling .pioenvs/pro16MHzatmega328/src/main.cpp.o
Compiling .pioenvs/pro16MHzatmega328/lib2cc/mylib/myclim.cpp.o
In file included from lib/mylib/myclim.cpp:1:0:
lib/mylib/myclim.h:5:17: fatal error: DHT.h: No such file or directory
*************************************************************
* Looking for DHT.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:DHT.h"
* Web > https://platformio.org/lib/search?query=header:DHT.h
*
*************************************************************
compilation terminated.
*** [.pioenvs/pro16MHzatmega328/lib2cc/mylib/myclim.cpp.o] Error 1
The content of platformio.ini
:
[env:promini]
platform = atmelavr
board = pro16MHzatmega328
framework = arduino
upload_port = /dev/ttyUSB*
Source file to reproduce issue:
/lib/mylib/mylib.h
#ifndef MYLIB_H
#define MYLIB_H
#include <Arduino.h>
void fn();
#endif
/lib/mylib/mylib.cpp
#include <mylib.h>
void fn()
{
Serial.println("fn1");
}
/lib/mylib/myclim.h
#ifndef MYCLIM_H
#define MYCLIM_H
#include <Arduino.h>
#include <DHT.h>
void fnclim();
#endif
/lib/mylib/myclim.cpp
#include <myclim.h>
void fnclim()
{
Serial.println("fnclim");
}
/src/main.cpp
#include <Arduino.h>
#include <mylib.h>
#include <myclim.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Add build dependencies - Android Developers
Learn how to add build dependencies using the Gradle build system in Android Studio. ... Dependency on a local library module
Read more >How to add local libraries to Gradle - Appmediation
Option 1. · Copy your JAR file to your module 'libs' folder. If you don't have 'libs' folder then create one. For example,...
Read more >Local libraries and include dependencies
Hi, all! I'm using PlatformIO in Atom for Arduino programming. I get dependencies error when build bellow code.
Read more >arduino uno - local libraries and include dependencies
I'm using PlatformIO in Atom for Arduino programming. I get dependencies error when build. This is my reproduction sample code:.
Read more >How can I add a local library as a dependency in Swift ...
First: package dependency can link to other packages only! It's possible from Swift 5.3 with binaryTarget but you should build your static ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
because you installed it before into the global Arduino scope? Just add to your
platformio.ini
See
Hi, @pfeerick. Excuse me, I think that I’m not understand something because my english.
The library DHT or any other that I use in myclim.h is installed, both in Arduino library path and PlatformIO library path. Then, the library exists. It makes sense that I not have a compiling error when include myclim in main source. But, why PlatformIO return error that not found library (when not include it main source) if library file exists and is installed?
If I don’t use myclim, not make sense compiling DHT and make final binary bigger than necessary (Arduino is limited in space). Maybe I’m not know the exactly process of compiling.
If I understand the output, PIO (PlatformIO) first pre compiling libraries included in main.cpp. Then DHT is pre compiled before compiling myclim (whem myclim is included in main.cpp). When I not include myclim in main cpp, PIO try compiling myclim and because DHT is not pre compiled, PIO return error. I think that PIO must search for dependency in local library. Then, PIO must “see” DHT in myclim, pre compiling it before compiling myclim. But the question is, why compiling myclim if I not using it when not include it in main.cpp?