Menu

#121 Is there a way to pull in a specific file from a library?

None
open
nobody
None
5
2018-12-07
2018-12-07
No

I need the linker to pull in main() from a library. But this doesn't happen automatically, there seem to be no external reference of main anywhere else.

The current workaround is to leave main.rel out when building the project library and list it on the linker command line instead.

This works most of the time, but due to the way the Arduino IDE handles the build and cache directories, linker errors due to a missing main.rel can happen when files are moved from build to cache.

Another way around this is to add a dummy variable to one of the source files that is initialized to &main. This pulls in the file containing main() from the library.

void (*dummy_variable) () = main;

Is there a third possiblility? Something that doesn't leave any traces in the output? Maybe a kind of void reference, a command line parameter or a linker configuration variable?

Discussion

  • Maarten Brock

    Maarten Brock - 2018-12-07
    • Group: -->
     
  • Maarten Brock

    Maarten Brock - 2018-12-07

    For starters I would make that dummy_variable const so it only consumes code space and not ram as well.

    And maybe you can use assembly and declare a .globl _main, I'm not sure.

     

Log in to post a comment.

Monday.com Logo