V "C error: undefined reference" at the cc step in CI
V transpiles to C and links the result with the system C compiler. An "undefined reference" at that step means a C symbol from a wrapped library has no definition because the library was not linked.
What this error means
The build fails after V finishes, with the cc/ld output showing "undefined reference to X" and "cannot find -l..." for a native library.
v
/usr/bin/ld: undefined reference to `sqlite3_open'
collect2: error: ld returned 1 exit status
builder error: C error. This should never happen.Common causes
A wrapped C library was not linked
A module calls into a C library but the link flag for it was missing, so ld cannot resolve the C symbols.
The development library is not installed
The dev package providing the library and its headers is absent on the runner, so the link cannot find it.
How to fix it
Install the dev library and link it
- Install the
-devpackage for the C library the module wraps. - Ensure the module declares the link flag (or pass it to the build).
- Re-run; the link succeeds once the library is found.
Terminal
sudo apt-get update && sudo apt-get install -y libsqlite3-devPass the link flag to the C backend
Tell V to link the native library when the module does not declare it.
Terminal
v -cflags -lsqlite3 build .How to prevent it
- Install dev packages for every C library your modules wrap.
- Declare link flags in modules that bind native libraries.
- List native system dependencies in the CI setup step.
Related guides
V "builder error: cannot find module" in CIFix V "builder error: cannot find module X" in CI - the V compiler could not locate an imported module under…
V "builder error: unknown type" in CIFix V "builder error: unknown type X" in CI - a type name is referenced that V cannot resolve because its mod…
V "builder error: function main must be declared" in CIFix V "builder error: function `main` must be declared in the main module" in CI - V is building an executabl…