alliedmodders / metamod-source

Metamod:Source - C++ Plugin Environment and Detour Library for the Source Engine
http://www.metamodsource.net/
Other
383 stars 87 forks source link

MMS: Fatal error: Detected engine 17 (+21 and 25) but could not load - Fistful of Frags, Pirates and Vikings and Knights II and Black Mesa #146

Closed PlayBoy31 closed 11 months ago

PlayBoy31 commented 11 months ago

For Fistful of Frags: Detected engine 17 but could not load: /servers/fof_ds/fof/../fof/addons/metamod/bin/metamod.2.sdk2013.so: undefined symbol: __pow_finite

For Pirates, Vikings and Knights II: Detected engine 24 but could not load: /servers/pvkii_ds/pvkii/../pvkii/addons/metamod/bin/metamod.2.pvkii.so: undefined symbol: __pow_finite

For Black Mesa: Detected engine 21 but could not load: /servers/bms_ds/bms/addons/metamod/bin/metamod.2.bms.so: undefined symbol: __pow_finite

With: SourceMod Version: 1.12.0.7071 Metamod:Source version 2.0.0-dev+1255 Debian 12.2 up to date

Have a look at: https://reviews.llvm.org/D74712

PlayBoy31 commented 11 months ago

Root cause: The *_finite calls have been removed on lib math (see https://reviews.llvm.org/D74712)

Temp fix for those who want to build it for those games until its fixed propoerly:

create a file mymath.c

#include <math.h>

double __pow_finite(double x, double y);
float __atan2f_finite(float y, float x);
float __atan2_finite(float y, float x);
float __log_finite(float num);
float __acosf_finite(float num);
float __acos_finite(float num);
float __asin_finite(float num);

double __pow_finite(double x, double y)
{
   return pow(x, y);
}

float __atan2f_finite(float y, float x)
{
   return atan2f(y, x);
}

float __atan2_finite(float y, float x)
{
   return atan2(y, x);
}

float __log_finite(float num)
{
   return log(num);
}

float __acosf_finite(float num)
{
   return acosf(num);
}

float __acos_finite(float num)
{
   return acos(num);
}

float __asin_finite(float num)
{
   return asin(num);
}

Compile it and create the lib:

gcc -m32 -c mymath.c
ar rcs libmymath.a mymath.o

Link your metamod build with this library

psychonic commented 11 months ago

Thanks. It seems this affects any game/mod that's compiled against libm from the Scout version of the Steam Runtime SDK

dvander commented 11 months ago

This is supposed to be fixed in the build by linking in https://github.com/alliedmodders/amtl/blob/master/compat/stdcxx.cpp

dvander commented 11 months ago

Oh, we never actually do that. That'd be why.