Ok. I've created a link map accidentally (I mean I don't remember which options I used but the "exbasic.map" file was created) and it has these lines inside:

Code:
Allocating common symbols
Common symbol    size       file

 ...
U_GLX_GLXQUERYEXTENSION
          0x4       /usr/lib/fpc/2.2.2/units/i386-linux/opengl/glx.o
 ...

Linker script and memory map

TARGET(elf32-i386)
 ..
LOAD /usr/lib/fpc/2.2.2/units/i386-linux/opengl/gl.o
 ...
LOAD lib/allegro.o
LOAD lib/algl.o
 ..
LOAD /usr/lib/fpc/2.2.2/units/i386-linux/opengl/glu.o
LOAD /usr/lib/fpc/2.2.2/units/i386-linux/opengl/glx.o
LOAD /usr/lib/fpc/2.2.2/units/i386-linux/x11/x.o
 ...
LOAD /usr/local/lib/liballeg-4.4.0.so
LOAD /usr/lib/libdl.so
LOAD /usr/lib/libm.so
LOAD /usr/lib/libX11.so
LOAD /usr/lib/libc.so
START GROUP
LOAD /lib/libc.so.6
LOAD /usr/lib/libc_nonshared.a
LOAD /lib/ld-linux.so.2
END GROUP
 ...
 COMMON     0x000000000809dd10   0x1a4 /usr/lib/fpc/2.2.2/units/i386-linux/opengl/glx.o
 ...
        0x000000000809dd50        U_GLX_GLXQUERYEXTENSION
 ...
 .debug_frame  0x0000000000000064    0x0 /usr/lib/fpc/2.2.2/units/i386-linux/opengl/gl.o
 ...
 .debug_frame  0x0000000000000064   0x1234 lib/allegro.o
 .debug_frame  0x0000000000001298   0x1a4 lib/algl.o
 ...
 .debug_frame  0x0000000000001694    0x0 /usr/lib/fpc/2.2.2/units/i386-linux/opengl/glu.o
 .debug_frame  0x0000000000001694    0x0 /usr/lib/fpc/2.2.2/units/i386-linux/opengl/glx.o
 ...
I'm not sure if I've listed all related lines, but if I've understood it links the GLX library and has information about the "glXQueryExtension", but for some reason the "libagl.so" can't link it. At the the Allegro forums a developer suggested that "(...) whether linking order could possibly make a difference. ".

This is getting weirder every day...