Debian, Custom LUA module - "Couldn't load module library!"

Hi, I’m trying to compile a simple testing module for debian (x64, jessie), but require(‘module’) gives me an error: Couldn’t load module library!
After that I run the server with “LD_LIBRARY_PATH=garrysmod/bin:bin:. LD_DEBUG=libs”, and got this:

28514:     <...>/garrysmod/lua/bin/gmsv_testmodule_linux.dll: error: symbol lookup error: undefined symbol: _Z14Sys_GetFactoryPKc (fatal)

[ERROR] addons/testmodule/lua/autorun/autoload.lua:18: Couldn't load module library!
  1. require - [C]:-1
   2. unknown - addons/testmodule/lua/autorun/autoload.lua:18

Module code:

#include <Lua/Interface.h>
#include <tier1.h>
#include <eiface.h>

	printf( "
[li] Opening test module ...[/li]" );
	auto engineFn = Sys_GetFactory( "" );

	return 0;

	printf( "[li] Test module exited[/li]" );
	return 0;

Module info:

$ ldd <...>/garrysmod/lua/bin/gmsv_testmodule_linux.dll (0xf7704000) => not found => not found => /usr/lib32/ (0xf7601000) => /lib/i386-linux-gnu/i686/cmov/ (0xf75bb000) => /lib/i386-linux-gnu/ (0xf759e000) => /lib/i386-linux-gnu/i686/cmov/ (0xf73f1000)
        /lib/ (0xf7707000)

IIRC Sys_GetFactory is defined in the tier1 library. Make sure your module is linking with tier1.a

There appears to be a missing referece to libtier0 and libvstdlib also.

That actually has nothing to do with it. Those libraries will already be loaded into gmod by the time this module loads, and won’t be an issue.

Thank you, I’ve been change the linker order to “-l:tier1.a -lvstdlib -ltier0” and that’s help.