{"record":{"id":"eed7279102b421f7","repo":"golang/go","slug":"internal-error-import-symbol-q-with-no-underlyin","errorCode":null,"errorMessage":"internal error: import symbol %q with no underlying sym","messagePattern":"internal error: import symbol %q with no underlying sym","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/link/internal/loadpe/ldpe.go","lineNumber":828,"sourceCode":"}\n\n// LookupBaseFromImport examines the symbol \"s\" to see if it\n// corresponds to an import symbol (name of the form \"__imp_XYZ\") and\n// if so, it looks up the underlying target of the import symbol and\n// returns it. An error is returned if the symbol is of the form\n// \"__imp_XYZ\" but no XYZ can be found.\nfunc LookupBaseFromImport(s loader.Sym, ldr *loader.Loader, arch *sys.Arch) (loader.Sym, error) {\n\tsname := ldr.SymName(s)\n\tif !strings.HasPrefix(sname, \"__imp_\") {\n\t\treturn 0, nil\n\t}\n\tbasename := sname[len(\"__imp_\"):]\n\tif arch.Family == sys.I386 && basename[0] == '_' {\n\t\tbasename = basename[1:] // _Name => Name\n\t}\n\tisym := ldr.Lookup(basename, 0)\n\tif isym == 0 {\n\t\treturn 0, fmt.Errorf(\"internal error: import symbol %q with no underlying sym\", sname)\n\t}\n\treturn isym, nil\n}\n","sourceCodeStart":810,"sourceCodeEnd":832,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/loadpe/ldpe.go#L810-L832","documentation":"The Go linker found an import symbol (a symbol whose name starts with `__imp_`) but the underlying symbol it is supposed to import (the name after the `__imp_` prefix) does not exist in the symbol table. On Windows PE, `__imp_XYZ` symbols are thunks that point to the actual imported function/variable `XYZ`. This is an internal linker consistency error: the PE file declared an import thunk without a corresponding definition.","triggerScenarios":"Fires in `LookupBaseFromImport` at ldpe.go:826-828 when `ldr.Lookup(basename, 0)` returns 0, meaning the symbol `XYZ` (after stripping `__imp_` and optionally a leading underscore on i386) was never created during symbol loading. The function is called during relocation processing for symbols that begin with `__imp_`.","commonSituations":"Linking against a Windows import library (.lib) that references DLL imports not actually linked into the final binary. Stale or mismatched .a/.lib files from a previous build where the underlying symbol was later removed or renamed. A bug in the Go linker's symbol processing order where `LookupBaseFromImport` is called before all symbols have been registered. Mixing 32-bit and 64-bit object files where the `_Name` -> `Name` mangling (i386 only) doesn't match what was expected.","solutions":["Ensure all required import libraries and DLL dependencies are available to the linker — check that `-L` paths include directories with the needed .lib/.a files.","Clean the build cache and rebuild to eliminate stale object files: `go clean -cache && go build`.","Update Go to the latest version — symbol processing order bugs are fixed over time.","If linking C code via cgo, verify the C compiler can build the code standalone (without Go) to rule out missing symbol definitions.","File a Go bug with the symbol name from the error message and the build configuration, as the error text explicitly labels this an 'internal error'."],"exampleFix":"# Ensure all import libraries are available and rebuild cleanly\ngo clean -cache\ngo build -v ./...\n\n# If using cgo with specific libraries, ensure CGO_LDFLAGS includes them:\nCGO_LDFLAGS=\"-L/path/to/libs -lmylib\" go build ./...","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure all import libraries referenced by cgo code are available in the linker search path.","Use go clean -cache before rebuilding after changing C dependencies.","Verify DLL imports match between .h declarations and .lib files.","Keep the i386 vs amd64 distinction clear — import symbol name mangling differs."],"tags":["linker","pe","import-symbol","windows","cgo","internal-error"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}