Skip to content

Linking issue / Multiple definitions #39

@aanas-sayed

Description

@aanas-sayed

Issue Summary

I'm getting a linker error when splitting my SCPI command setup into separate files:

C:\Users\xxx\AppData\Local\Temp\arduino_build_706583\sketch\scpi_interface.cpp.o (symbol from plugin): In function `DefaultErrorHandler(SCPI_Commands, SCPI_Parameters, Stream&)':
(.text+0x0): multiple definition of `DefaultErrorHandler(SCPI_Commands, SCPI_Parameters, Stream&)'

Works:

  • Everything compiles fine if I put all SCPI setup and handlers in main.ino.

Fails:

  • When I move SCPI setup into scpi_implementation.h (included only in main.ino), I get the error above.

Details:

  • Vrekrer_scpi_parser.h is only included in scpi_implementation.h, not multiple times.
  • The issue seems to come from this in the header:
#include "Vrekrer_scpi_parser_code.h"

Since that file includes implementations, including it from a .h file causes multiple definitions when the header is used across files.

Workaround:

  • Putting everything in main.ino avoids the issue, probably because it's compiled as one translation unit.

Thanks so much for this great project — I was using another SCPI library before, but it was too heavy for my needs. This one is much more lightweight and exactly what I was looking for!

Would love to know if there’s a recommended way to structure this, or if you’ve considered moving the implementations to .cpp files to avoid these issues. I understand there’s likely a reason for the current setup — I just can’t quite follow the rationale yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions