Hi there
I’m trying to compile both native and esp32 environments using a shared library, however, it compiles and executed fine at esp32, but sereral errors arised on native environment.
First, it doesn’t recognize the added library lib_deps
config.
Solved by overriding this issue by adding -I<path-to-lib-src>
inside build_flags
, but a linking error regarding the library API is arised undefined reference to ...
.
platformio.ini:
[platformio]
default_envs =
esp32doit
[common]
lib_deps =
https://github.com/HamzaHajeir/pmbtools.git
build_flags =
lib_ldf_mode = deep+
[embedded]
lib_deps =
${common.lib_deps}
build_flags =
-std=gnu++2a
-DEMBEDDED_PLATFORM=1
${common.build_flags}
lib_ldf_mode = ${common.lib_ldf_mode}
build_unflags =
-std=gnu++11
monitor_speed = 115200
upload_speed = 921600
[esp32]
lib_deps =
${embedded.lib_deps}
build_flags =
-DESP32=1
-DARDUINO_ARCH_ESP32=1
-DBOARD_HAS_PSRAM
${embedded.build_flags}
build_unflags =
${embedded.build_unflags}
lib_ldf_mode = ${embedded.lib_ldf_mode}
[env:esp32doit]
platform = espressif32@^5.2.0
board = esp32doit-devkit-v1
framework = arduino
lib_deps =
${esp32.lib_deps}
lib_ldf_mode = ${esp32.lib_ldf_mode}
build_flags =
${esp32.build_flags}
build_unflags =
${esp32.build_unflags}
[env:native]
platform = native
lib_deps =
${common.lib_deps}
lib_ldf_mode = ${common.lib_ldf_mode}
build_flags =
${common.build_flags}
-I .pio/libdeps/native/pmbtools/src
-std=c++20
-O2
build_unflags =
-std=c++11
main.cpp:
#include "pmbtools.h"
void call()
{
auto rv = join({"Hello", " ", "world"});
}
#ifdef EMBEDDED_PLATFORM
#include <Arduino.h>
void setup()
{
// put your setup code here, to run once:
call();
}
void loop()
{
// put your main code here, to run repeatedly:
}
#else
int main()
{
call();
}
#endif
The complete environment is uploaded to GitHub.
Any idea/solution?