Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Solution for adding support for pre-compiled Libraries

  1. #1
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    270

    Solution for adding support for pre-compiled Libraries

    Anyone know which of Paul's repos on Github is for the Teensyduino files with regards to the following file. I can't seem to find which one it is and I'd like to make a pull request to get support for precompiled libraries working.

    hardware/teensy/avr/platform.txt

    Arduino IDE added support for precompiled libraries, it was discussed here previously, but there is an easier solution (see below):
    https://forum.pjrc.com/threads/50172...mpiled-library

    I really need to use precompiled libraries for a project so I looked into this, it's actually pretty easy to solve now. I used this very helpful link as a reference:
    https://forum.arduino.cc/index.php?topic=653746.0

    TL;DR

    The following changes must be made to the platform.txt file:

    1) Insert {compiler.libraries.ldflags} in the correct loocation to the recipe.c.combine.pattern, after the {object_files}
    Code:
    ## Link
    recipe.c.combine.pattern="{compiler.path}{build.toolchain}{build.command.linker}" {build.flags.optimize} {build.flags.ld} {build.flags.ldspecs} {build.flags.cpu} -o "{build.path}/{build.project_name}.elf" {object_files} {compiler.libraries.ldflags} "{build.path}/{archive_file}" "-L{build.path}" {build.flags.libs}
    2) Add 'compiler.libraries.ldflags=' to the platform.txt file, I threw it at the end
    Code:
    compiler.libraries.ldflags=
    That's it for changes to Teensyduino.

    3) To build your library, you must add the following option to your library.properties file in order to have the compiler output the static library .a file.
    Code:
    dot_a_linkage=true
    4) Compile the library and go grab the YourLibrary.a file from /tmp/<build otuput>

    5) Package up (zip) your library as follows:
    MyLibrary/library.properties
    MyLibrary/src/<arch>/libYourLibrary.a
    MyLibrary/src/<public header files only>

    5a) remove the dot_a_linkage in your packaged version and replace with the following two lines:
    Code:
    precompiled=true
    ldflags=-lMyLibrary
    5b) figure our the arch you targeting. For example for Teensy 4.X, its 'imxrt1062'. You need to separately compile and package for each architecture you are targeting.
    5c) notice we have to rename YourLibrary.a to libYourLibrary.a in the package.

    You can do these steps yourself in the meantime. If I can get a pull request to update the platform.txt file in Teensyduino, Steps 1 & 2 would already be done.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,404
    Paul deals with platform & boards files behind the scenes AFAIK

  3. #3
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    270
    Quote Originally Posted by defragster View Post
    Paul deals with platform & boards files behind the scenes AFAIK
    Thanks, I'll try reaching out to Paul directly then.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,749
    Indeed those files aren't on github.

  5. #5
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    270
    Quote Originally Posted by PaulStoffregen View Post
    Indeed those files aren't on github.
    Any chance of getting that small addition to the platform.txt file? Similar changes have been made on other Arduino compatible boards to support the precompiled library feature.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •