Fix: 'error 017: undefined symbol' in Pawn

May 21, 2025 Daemon666 7 min read 18 vistas

error 017: undefined symbol "x" is the single most common failure people hit when compiling AMX Mod X plugins, and it means exactly one thing: the compiler reached an identifier it has no declaration for. Pawn is strongly typed and single-pass over declarations, so every function, native, constant and variable must be visible before the line that uses it. The symbol name in quotes is the whole diagnosis — read it first, then work through the causes below in order.

1. A missing #include

Natives live in include files, not in the compiler. If you call get_user_flags() without #include <amxmodx>, or a Ham function without #include <hamsandwich>, you get 017 on that exact native. Every plugin needs at least:

#include <amxmodx>
#include <amxmisc>

Then add one line per module you touch — <fakemeta>, <hamsandwich>, <cstrike>, <fun>, <sqlx>. Map the undefined symbol to the include that declares it. If you are new to this, writing your first plugin walks through the standard header block.

2. The native exists — but not in your AMXX version

This trap catches experienced coders. client_print_color() was added in AMX Mod X 1.9. If your include/ folder is from 1.8.2, the compiler has never heard of it and throws 017. The fix is not to hack the include — it is to compile against 1.9 or 1.10 headers and set your plugin's minimum to match. The reverse also happens: you copied a single .inc into a 1.8.2 tree without the natives behind it. Confirm which toolchain you are on before you blame the code; see compiling .sma to .amxx for pinning the compiler version.

3. A typo or a case mismatch

Pawn identifiers are case-sensitive. get_user_Name is a different symbol from get_user_name, and the compiler will not guess. Watch for:

  • Capitalisation: Float: the tag versus float.
  • Underscores: is_user_alive, not isuseralive.
  • A constant you meant to #define but spelled differently at the use site.

4. Using a symbol before it is declared

Pawn reads top to bottom. A #define or a global used above its declaration is undefined at that point:

public plugin_init() {
    set_task(TASK_TIME, "tick")   // 017: TASK_TIME not yet defined
}
#define TASK_TIME 1.0

Move constants and globals to the top of the file. Functions are more forgiving — Pawn resolves ordinary function calls in a later pass — but constants and globals must precede their first use.

5. A public callback that was never written

When you register a handler by name, the compiler must find a public function with that exact name:

register_event("DeathMsg", "OnDeath", "a")
// ...
public OnDeath(id) { /* ... */ }   // must exist, spelled identically

Note that a missing callback more often shows as error 017 only if you reference the function elsewhere; a bare string mismatch fails silently at runtime instead. Still, keep the registered string and the public name identical.

Common errors that look like 017 but are not

  • error 021: symbol already defined — the opposite problem: two globals or two functions share a name. Rename one.
  • warning 213: tag mismatch — usually a Float: passed where a cell is expected. Not fatal, but fix it; it is a real bug most of the time.
  • error 088: number of arguments does not match definition — the native exists and is included, you just called it with the wrong argument count. Check the include for the real signature.
  • 017 on a whole cluster of symbols at once — almost always a single missing #include near the top, not many separate bugs. Fix the include and recompile before chasing the rest.

Verification

Recompile and read the summary line. A clean build ends with something like:

Header size:          1234 bytes
Code size:            5678 bytes
...
0 Errors.

Only 0 Errors. produces a usable .amxx; a build with errors writes nothing. If you compile inside an editor, set it up as in the VS Code AMXX setup so the exact line and symbol jump out. Once it builds, drop the .amxx into addons/amxmodx/plugins/, add it to plugins.ini, and confirm it loads with amxx list in the server console — a plugin that compiled but shows bad load there is a different problem (usually a missing module) covered in the module load fix.

Colaboradores: Daemon666 ✦
Compartir: