-
-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library cross-linking doesn't work correctly #50
Comments
PlatformIO is flexible tool. You can define own build flags within 3 options:
P.S: I'm working on the new finder for dependent library with nested logic. It will analyze all source files and find for the libs automatically and include them. |
Yeah, I was already playing with the build flags. Thanks for the pointer on the PIOSRCBUILD_FLAGS variable, that'll be useful for scripting what I have in mind. I have a slowly growing batch of arduino-based modules sharing similar hardware but with different configurations beyond that stored in EEPROM, so my ultimate goal is to have a build script that reads the EEPROM, sets build flags, and then builds & uploads from a single source tree (rather than the git branches I have to deal with now). From all I've seen platformio should be great for doing this sort of thing, once the other complexities of my setup are worked out. Thanks for looking into the nested library logic. Hopefully at some point I'll get the time to fix my own issues here, I just haven't had the time to thoroughly dig through your code base yet. |
@aphelps can you retest it with the latest $ pip uninstall platformio
$ pip install https://github.com/ivankravets/platformio/archive/develop.zip Thanks a lot! If you have any problems, please reopen this issue. |
I did the uninstall/install and tried 'platformio run -t clean; platformio run' with the simple git repo I linked to above and it hits the same error. Can you get that example code running? It looks like I can't re-open this issue directly, it appears only project collaborators can reopen and issue once its closed. |
This issue is linked with I spent a lot of time to implement virtual "Library Dependency Finder" which has behaviour close to C Preprocessor. It allows to be PlatformIO extremely FAST! PlatformIO recompiles only changed files from your So... If we use "static" libraries, we have to control the order for them manually. I mean under "libs order", the "order" for I recommend to read this great explanation about gcc-linker.
In your case, library
#include <Arduino.h>
#include "TestLib2.h"
#include "TestLib1.h" But... We can skip [env:arduino_nano]
platform = atmelavr
framework = arduino
board = nanoatmega328
build_flags = -Wl,--start-group I understand that this sounds complicated for you after Arduino IDE. We should relay on Arduino IDE like "right behaviour". Arduino IDE has a few "non-standart" issues which break generic logic of source code building. For example, a
Sorry, I don't want to blame Arduino IDE because they simplify a lot of things. PlatformIO also tries to simplify cross-platform code building. If you have any questions, don't hesitate to discuss here. |
Yeah, I'm actually very familiar with non-Arduino C development, though I admit its been a while since I've dealt directly with the linker. I'll see if I can rearrange include order in my actual project (rather than this trivial example I set up) to get it building on both the IDE and platformio. I can't guarantee that's possible though, as some of the libraries I'm using are 3rd party ones from Adafruit which have some inter-dependencies. I think it should be a goal to be able to take a project that builds in the Arduino IDE directly to platformio with as little hassle as possible, but I do understand that the IDE does builds in weird and aggravating ways. If I was the only user of this thing I'm working on I wouldn't care as much about compatibility, but I'm going to need to be able to share this with people that may have never used the MacOS command line. |
You shouldn't rearrange anything. Your existing libs should work with PlatformIO without any changes.
Which libs do you use? Are they located within PlatformIO Library Manager? If no, I can add them.
I want to promise you that Arduino-based libs are compatible with PlatformIO in 99% 😄 Thanks a lot! 👍 |
@aphelps I've just enabled "cyclic dependencies" by default for |
With the "cyclic dependencies" change my actual project now compiles and uploads, thanks! This is looking awesome. As for the 3rd party libraries, the big one is https://github.com/FastLED/FastLED. Now that I can build I can work on getting the libraries I've been using for this added to the library manager. |
Thanks a lot for testing 👍 I hope, I will release 0.11.0 in next week.
Done. http://platformio.org/#!/lib/show/126/FastLED |
Sorry about the continuing issues as I work on converting my stuff from using the Arduino IDE to platformio, but the main reason I'm trying to move it is that it was getting to complex for the IDE and I need some more flexibility (particularly the ability to pass environment variables into compilation), so I probably have a more complicated code structure than folks are usually using with an arduino.
My next issue I think boils down to libraries not being cross linked correctly. For instance if library1 uses code from library2 I'm seeing linker errors. I've made a minimal example demonstrating the problem here:
https://github.com/aphelps/platformio_test/tree/master/test_library_crosslink
With the code as is, the compilation fails:
This fails because the function TestLib2_Test() is in library TestLib2 which calls TestLib1_Test() in library TestLib1. However if you uncomment a call to TestLib1_Test() in main.ino that function will be compiled and the linker finds it: https://github.com/aphelps/platformio_test/blob/master/test_library_crosslink/src/main.ino#L9
The text was updated successfully, but these errors were encountered: