Skip to content

Building a library without linking attempt #5128

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

Open
matthiashanns opened this issue Apr 4, 2025 · 0 comments
Open

Building a library without linking attempt #5128

matthiashanns opened this issue Apr 4, 2025 · 0 comments

Comments

@matthiashanns
Copy link

Problem

Library projects contain their sources in src/ and include/ and don't have a main() function. Building such a project first compiles the code and subsequently tries to link it unnecessarily. The linker, however, fails by complaining about a missing main() or missing setup() and loop() (depending on whether, e.g., the arduino framework is in use).

There is no project parameter in platformio.ini to tell pio not to link a library project. There is also no build parameter to the compiler (eg. gcc) to suppress the linker since the linker is started exclusively by pio. A custom build script could be used, but it should not be required for a common task like building a library project.

Expected behavior

Building a library project should contain the steps of compiling, optionally creating a library archive (.a), and optionally including an archive index, but no linking step.

  • A project should be markable as a library project in platformio.ini (eg. type = library with type defaulting to application) to omit the linking step and avoid a linking error and hence a build error.
  • Additionally, a compile-only build option should exist that compiles without linking to quickly build a library project or check the code for compile errors on any project, saving the linker time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants