garrysmod_common icon indicating copy to clipboard operation
garrysmod_common copied to clipboard

undefined symbol: gmod13_open

Open 0xGodspeed opened this issue 8 months ago • 0 comments

module.cpp

#include "GarrysMod/Lua/Interface.h"

#include <fcntl.h>
#include <iostream>
#include <unistd.h>

/*
	require "HelloWorld"
	print( TestFunction( 5, 17 ) )
*/

using namespace GarrysMod::Lua;
using namespace std;

LUA_FUNCTION( MyExampleFunction )
{
	double first_number = LUA->CheckNumber( 1 );
	double second_number = LUA->CheckNumber( 2 );

	LUA->PushNumber( first_number + second_number );
	return 1;
}

LUA_FUNCTION( MyExampleFunction2 )
{
	double first_number = LUA->CheckNumber( 1 );
	double second_number = LUA->CheckNumber( 2 );

	LUA->PushNumber( first_number * second_number );
	return 1;
}

GMOD_MODULE_OPEN()
{
	LUA->PushSpecial( GarrysMod::Lua::SPECIAL_GLOB );
	LUA->PushString( "TestFunction1" );
	LUA->PushCFunction( MyExampleFunction );
	LUA->SetTable( -3 ); // `_G.TestFunction = MyExampleFunction`
	return 0;
}

GMOD_MODULE_CLOSE()
{
	return 0;
}

premake.lua

PROJECT_GENERATOR_VERSION = 3

newoption({
	trigger = "gmcommon",
	description = "Sets the path to the garrysmod_common (https://github.com/danielga/garrysmod_common) directory",
	value = "../garrysmod_common"
})

local gmcommon = assert(_OPTIONS.gmcommon or os.getenv("GARRYSMOD_COMMON"),
	"you didn't provide a path to your garrysmod_common (https://github.com/danielga/garrysmod_common) directory")
include(gmcommon)

CreateWorkspace({name = "binmod", abi_compatible = false, path = "projects/" .. os.target() .. "/" .. _ACTION})
	CreateProject({serverside = true, source_path = "source", manual_files = false})
		IncludeLuaShared()
		IncludeScanning()
		IncludeDetouring()
		IncludeSDKCommon()
		IncludeSDKTier0()
		IncludeSDKTier1()

	CreateProject({serverside = false, source_path = "source", manual_files = false})
		IncludeLuaShared()
		IncludeScanning()
		IncludeDetouring()
		IncludeSDKCommon()
		IncludeSDKTier0()
		IncludeSDKTier1()

		filter("system:windows")
			files({"source/win32/*.cpp", "source/win32/*.hpp"})

		filter("system:linux or macosx")
			files({"source/posix/*.cpp", "source/posix/*.hpp"})

The client mod is not working and shows this error during runtime when I try to include it in a mod.

[ERROR] lua/autorun/client/test_mod_client.lua:80: Couldn't find function in library! (/home/afterchange/.steam/debian-installation/steamapps/common/GarrysMod/garrysmod/lua/bin/gmcl_binmod_linux.dll: undefined symbol: gmod13_open)
  1. require - [C]:-1
   2. unknown - lua/autorun/client/test_mod_client.lua:80

0xGodspeed avatar Jun 10 '24 07:06 0xGodspeed