Building a library without linking attempt

Open
#5,128 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
arduino

Research direction

Start by tracing how platformio.ini project settings reach the build and linker invocation; the issue specifically proposes a library project type and a compile-only option. Verify completion by building a library without a main(), confirming compilation succeeds without linking, and checking the requested optional archive and index behavior.

Written by the indexing model from the issue text.

Description

build system feature
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.
Dominant language
Python
Stars
9.6k
Forks
916
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from platformio/platformio-core

All issues in platformio/platformio-core

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.