rehlds / resemiclip

ReSemiclip
http://www.dedicated-server.ru/vbb/showthread.php?t=26898
GNU General Public License v2.0
13 stars 11 forks source link

[Question] How to build on Linux #16

Open rtxa opened 1 year ago

rtxa commented 1 year ago

Hi, I'm trying to compile resemiclip on Linux but I'm not sure how to. I see that you need Intel Compiler, but which one? I don't see reasonable that you have to download 4gb just to do some pretty basic task, any special reason why you are using that compiler instead of GCC?

justgo97 commented 1 year ago

I remember facing a similar issue, I just edited the make file to use GCC compiler instead and probably did few minor changes to make the compiler happy then the module worked fine on my server, I'm not sure if I still have the edited files but as I said it's a few minutes changes.

They probably used ICC because it "theoretically" produces more optimized binaries, but I think the difference is trivial

rtxa commented 1 year ago

@justgo97 You'll make me happy if you send me the modified file.

Good to know the reason isn't because of a compatibility issue with ReHLDS.

justgo97 commented 1 year ago

@justgo97 You'll make me happy if you send me the modified file.

Good to know the reason isn't because of a compatibility issue with ReHLDS.

Sadly I don't have the files, It seems they are lost with my old HDD

HLSDK = cssdk
METAMOD = metamod
M_INCLUDE = include

NAME = resemiclip

COMPILER = g++

OBJECTS = src/precompiled.cpp src/h_export.cpp src/gamedll_api.cpp src/engine_rehlds_api.cpp \
        src/meta_api.cpp src/main.cpp src/config.cpp cssdk/public/interface.cpp

LINK = -static-libgcc

OPT_FLAGS = -O3 -msse3 -funroll-loops -fomit-frame-pointer -fno-stack-protector

INCLUDE = -I. -I$(M_INCLUDE)/ -I$(HLSDK)/common -I$(HLSDK)/dlls -I$(HLSDK)/engine \
        -I$(HLSDK)/game_shared -I$(HLSDK)/pm_shared -I$(HLSDK)/public -I$(METAMOD)

BIN_DIR = Release
CFLAGS = $(OPT_FLAGS)

CFLAGS += -g -DNDEBUG -Dlinux -D__linux__ -D__USE_GNU -D_vsnprintf=vsnprintf -std=c++0x -shared -fPIC -m32

OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)

$(BIN_DIR)/%.o: %.c
    $(COMPILER) $(INCLUDE) $(CFLAGS) -o $@ -c $<

all:
    mkdir -p $(BIN_DIR)

    $(MAKE) $(NAME) && strip -x $(BIN_DIR)/$(NAME)_mm_i386.so

$(NAME): $(OBJ_LINUX)
    $(COMPILER) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -o$(BIN_DIR)/$(NAME)_mm_i386.so

check:
    cppcheck $(INCLUDE) --quiet --max-configs=100 -D__linux__ -DNDEBUG .

debug:
    $(MAKE) all DEBUG=false

default: all

clean:
    rm -rf Release/*.o
    rm -rf Release/$(NAME)_mm_i386.so

This is how the makefile should probably look like, There will also be a need to do some edits to the include files because the compiler seems to not behave the same way as ICC and some declarations have to be more accessible unless there are other flags to give to GCC to handle this that I don't know of. Also I used this command to pass the first compiling step

"sude apt-get install gcc-multilib g++-multilib"

But then I got some errors about some declarations not being accessible.

justgo97 commented 1 year ago

Updated the makefile as I forgot some changes.

Edit: Thanks to ChatGPT

rtxa commented 1 year ago

I tested this and I'm still getting errors in rehlds_api.h

In file included from include/precompiled.h:12,
                 from src/precompiled.cpp:1:
cssdk/engine/rehlds_api.h: At global scope:
cssdk/engine/rehlds_api.h:185:30: error: use of enum ‘sv_delta_s’ without previous declaration
  185 | typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
      |                              ^~~~~~~~~~
cssdk/engine/rehlds_api.h:185:103: error: template argument 2 is invalid
  185 | hain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
rtxa commented 1 year ago

PD: Also tried to build with Github Actions using an Actions with Intel OneApi but no succeed... Here is the link to my build.yml and modified Makefile removing some unrecognized flags.

https://github.com/rtxa/ReSemiclipHL/blob/actions/.github/workflows/build.yml https://github.com/rtxa/ReSemiclipHL/blob/actions/Makefile

justgo97 commented 1 year ago

I tested this and I'm still getting errors in rehlds_api.h

In file included from include/precompiled.h:12,
                 from src/precompiled.cpp:1:
cssdk/engine/rehlds_api.h: At global scope:
cssdk/engine/rehlds_api.h:185:30: error: use of enum ‘sv_delta_s’ without previous declaration
  185 | typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
      |                              ^~~~~~~~~~
cssdk/engine/rehlds_api.h:185:103: error: template argument 2 is invalid
  185 | hain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;

I think moving some declarations should fix it, like this one should probably be in cssdk/engine/rehlds_api.h or somewhere more accessible

typedef enum sv_delta_s
{
    sv_packet_nodelta,
    sv_packet_delta,
} sv_delta_t;
rtxa commented 1 year ago

I finally fixed the issue by moving the definition of sv_delta_s from include/engine_rehlds_api.h to cssdk/engine/maintypes.h. Latest version from ReAPI just do it this way.

justgo97 commented 1 year ago

I finally fixed the issue by moving the definition of sv_delta_s from include/engine_rehlds_api.h to cssdk/engine/maintypes.h. Latest version from ReAPI just do it this way.

Yep that should do it, I think that's also how I did it when I was playing with this years ago, This might be offtopic but I think the module could be heavily optimized by using the new SV_AllowPhysent hook in recent ReHLDS version rather than rebuilding the whole physent array in PM_Move, So a module is not needed for those running latest ReHLDS builds https://github.com/dreamstalker/rehlds/pull/951

rtxa commented 1 year ago

Thanks, I didn't know about that. Maybe I'll prototype a semiclip version for HL in AMXX which will allow people to use an API for their custom game modes, avoiding too much hassle. Of course, when I have some time.