| name | autofix-symbol-dep |
| description | Fixes linker 'undefined reference' errors by finding and adding the library dependency. |
Symbol Dependency Skill
Fixes linker errors where symbols cannot be resolved.
Detection Patterns
undefined reference to 'X'
unresolved external symbol X (MSVC)
ld.lld: error: undefined symbol: X
Strategy
- Extract Symbol: Parse the mangled or demangled symbol name.
- Find Library: Search for which library defines the symbol.
- Add Dependency: Update build file to link against the library.
Instructions
Step 1: Extract Symbol Name
From: undefined reference to '_ZN5MyApp10initializeEv'
Demangle: MyApp::initialize()
Step 2: Find the Defining Library
Search for the symbol definition:
grep -r "void MyApp::initialize" --include="*.cpp"
grep -r "class MyApp" --include="*.h"
Then find which build target compiles that source file.
Step 3: Add Dependency
GN (BUILD.gn):
deps = [
"//path/to:my_library",
]
Soong (Android.bp):
shared_libs: ["libmyapp"],
static_libs: ["libmyapp"],
CMake:
target_link_libraries(my_target PRIVATE my_library)
Step 4: Verify
Re-run the linker or full build to confirm resolution.
Common Android Libraries
| Symbol Pattern | Library |
|---|
android:: | libutils, libcutils |
AudioFlinger | libaudioflinger |
binder:: | libbinder |