| name | autofix-multiple-def |
| description | Fixes 'multiple definition' linker errors by removing duplicate symbols. |
Multiple Definition Skill
Fixes linker errors where the same symbol is defined in multiple translation units.
Detection Patterns
multiple definition of 'X'
already defined in
duplicate symbol
Strategy
- Identify Symbol: Extract the duplicated symbol.
- Find Definitions: Locate all places where it's defined.
- Remove Duplicates: Keep one, remove or fix others.
Instructions
Step 1: Parse Error
From: multiple definition of 'globalVar'; first defined in a.o
Step 2: Common Causes & Fixes
Global variable in header:
int globalVar = 0;
extern int globalVar;
int globalVar = 0;
inline int globalVar = 0;
Function defined in header:
void foo() { ... }
inline void foo() { ... }
Same source compiled twice:
Check build file for duplicate source file entries.