Raised This Month: $ Target: $400
 0% 

Compiling "standard" HL2 plugins with Cygwin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
squeeek
Junior Member
Join Date: Mar 2005
Location: Hungary - Budapest
Old 08-13-2006 , 09:27   Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #1

I know there are loads of topics and a Wiki about this stuff, but I just cant find the one that suits my needs.
Ive got the working plugin for windows servers, written with VS.net 2003.
Ive installed Cygwin, and unpacked the CrossTool with it.

My problem is, that I cant figure out, what the hell should I write to the makefile variables.
Every help is appriciated

Last edited by squeeek; 08-13-2006 at 09:31. Reason: fucked it up xD
squeeek is offline
Send a message via MSN to squeeek
squeeek
Junior Member
Join Date: Mar 2005
Location: Hungary - Budapest
Old 08-13-2006 , 14:36   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #2

or at least point me to the neccesary thread... =/
thank you in advance
squeeek is offline
Send a message via MSN to squeeek
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 08-13-2006 , 16:06   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #3

I really don't know much about makefiles. I would suggest taking a look at the makefile for the sample_mm plugin from Metamod: Source. I know you are doing a standard plugin, but it should be basically the same except you don't need the paths to sourcemm.

Also, search for tutorials/howtos about gcc and makefiles.
L. Duke is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 08-14-2006 , 04:03   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #4

Take a look at this tutorial I wrote a while back.

Its aimed at compiling for sourcemm but the principles are still the same. You can remove all referances to SMM_ROOT from the sample makefile provided.
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
squeeek
Junior Member
Join Date: Mar 2005
Location: Hungary - Budapest
Old 08-14-2006 , 04:38   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #5

jeeez, thanks guys!
now, my next problem is with the crosstool. I cant make out any logic in its folder-structure (i know its my false )

Code:
# Path to the HL2SDK src directory
SOURCE_DIR=/cygdrive/e/servercoding/Source

# the directory the base binaries (tier0_i486.so, etc) are located
#GAME_DIR=../../
GAME_DIR=/cygdrive/e/servercoding/hl2bin

# compiler options (gcc 3.4.1 or above is required)
CC=/usr/bin/gcc
CPLUS=/usr/bin/g++
CLINK=/usr/bin/gcc
CPP_LIB=/usr/lib/libstdc++.a /usr/lib/libgcc_eh.a

# the CPU target for the build, must be i486 for now
ARCH=i486
ARCH_CFLAGS=-mtune=i686 -march=pentium -mmmx -O3

# -fpermissive is so gcc 3.4.x doesn't complain about some template stuff
BASE_CFLAGS=-fpermissive -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp
SHLIBEXT=so
SHLIBCFLAGS=-fPIC
SHLIBLDFLAGS=-shared -Wl,-Map,$@_map.txt -Wl

# the dir we want to put binaries we build into
BUILD_DIR=.
# the place to put object files
BUILD_OBJ_DIR=$(BUILD_DIR)/obj

PUBLIC_SRC_DIR=$(SOURCE_DIR)/public
TIER1_SRC_DIR=$(SOURCE_DIR)/tier1
TIER0_PUBLIC_SRC_DIR=$(SOURCE_DIR)/public/tier0

PLUGIN_OBJ_DIR=$(BUILD_OBJ_DIR)/plugin
PUBLIC_OBJ_DIR=$(BUILD_OBJ_DIR)/plugin/public
TIER1_OBJ_DIR=$(BUILD_OBJ_DIR)/plugin/tier1
TIER0_OBJ_DIR=$(BUILD_OBJ_DIR)/plugin/tier0

CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) -Usprintf=use_Q_snprintf_instead_of_sprintf -Ustrncpy=use_Q_strncpy_instead -UPROTECTED_THINGS_ENABLE
#DEBUG = -g -ggdb
#CFLAGS+= $(DEBUG)

# link flags for your mod, make sure to include any special libraries here
LDFLAGS=-lm -ldl tier0_i486.so vstdlib_i486.so

INCLUDEDIRS=-I$(SOURCE_DIR)/public/tier0 -I$(SOURCE_DIR)/public/tier1 -I$(SOURCE_DIR)/public/dlls -I$(SOURCE_DIR)/public/game_shared -I$(SOURCE_DIR)/public -Iinclude

DO_CC=$(CPLUS) $(INCLUDEDIRS) -w $(CFLAGS) -DARCH=$(ARCH) -o $@ -c $<

#####################################################################

# list your files here
PLUGIN_OBJS = \
   $(PLUGIN_OBJ_DIR)/hybridmod_interface.o \
   $(PLUGIN_OBJ_DIR)/hybridmod_convar.o \
   $(PLUGIN_OBJ_DIR)/strings.o \

# all here are SDK .cpp's we need/want - sorted by source directory
PUBLIC_OBJS =

TIER1_OBJS = \
   $(TIER1_OBJ_DIR)/convar.o \
   $(TIER1_OBJ_DIR)/interface.o \
   $(TIER1_OBJ_DIR)/KeyValues.o \
   $(TIER1_OBJ_DIR)/utlbuffer.o \

TIER0_OBJS = \
   $(TIER0_OBJ_DIR)/memoverride.o \

all: dirs libs hybridmod_$(ARCH).$(SHLIBEXT)

dirs:
   -mkdir -p $(BUILD_OBJ_DIR)
   -mkdir -p $(PLUGIN_OBJ_DIR)
   -mkdir -p $(PUBLIC_OBJ_DIR)
   -mkdir -p $(TIER1_OBJ_DIR)
   -mkdir -p $(TIER0_OBJ_DIR)
libs:
   -ln -sf $(GAME_DIR)/tier0_i486.so
   -ln -sf $(GAME_DIR)/vstdlib_i486.so

hybridmod_$(ARCH).$(SHLIBEXT): $(PLUGIN_OBJS) $(PUBLIC_OBJS) $(TIER1_OBJS) $(TIER0_OBJS)
   $(CLINK) $(DEBUG) -o $(BUILD_DIR)/$@ $(SHLIBLDFLAGS) $(PLUGIN_OBJS) $(PUBLIC_OBJS) $(TIER1_OBJS) $(TIER0_OBJS) $(CPP_LIB) $(LDFLAGS) $(CPP_LIB)

$(PLUGIN_OBJ_DIR)/%.o: ./%.cpp
   $(DO_CC)

$(PUBLIC_OBJ_DIR)/%.o: $(PUBLIC_SRC_DIR)/%.cpp
   $(DO_CC)

$(TIER1_OBJ_DIR)/%.o: $(TIER1_SRC_DIR)/%.cpp
   $(DO_CC)

$(TIER0_OBJ_DIR)/%.o: $(TIER0_PUBLIC_SRC_DIR)/%.cpp
   $(DO_CC)

clean:
   -rm -rf $(BUILD_OBJ_DIR)
   -rm -f hybridmod_$(ARCH).$(SHLIBEXT)
SOURCE_DIR : the root of the unpacked SDK where "Everything_SDK.sln" and "Game_sdk.sln" are. (i hope so)
GAME_DIR : understood, thats simple. linux binaries

# compiler options (gcc 3.4.1 or above is required)
CC=/usr/bin/gcc
CPLUS=/usr/bin/g++
CLINK=/usr/bin/gcc
CPP_LIB=/usr/lib/libstdc++.a /usr/lib/libgcc_eh.a

My problem is with these lines. Ive found the first three in the unpacked crosstool: "cygwin\opt\crosstool\gcc-3.4.1-glibc-2.3.2\i686-unknown-linux-gnu\i686-unknown-linux-gnu\bin"
ar.exe, as.exe, c++.exe, g++.exe, gcc.exe etc...
Even got the libstdc++.a in the appropriate lib directory of that lengthy path.

The only "libgcc_eh.a" that Ive found within the crosstool folders was in "cygwin\opt\crosstool\gcc-3.4.1-glibc-2.3.2\i686-unknown-linux-gnu\lib\gcc\i686-unkown-linux-gnu\3.4.1"
Though the CPP_LIB should point to a single directory. What am i supposed to do? Im prettry sure something exra has to be done with the unpacked crosstool before you can use it for compiling.
Copy-paste? I wont try it all by myself, im sure i would mess up everything

all the best!

Last edited by squeeek; 08-14-2006 at 04:43.
squeeek is offline
Send a message via MSN to squeeek
squeeek
Junior Member
Join Date: Mar 2005
Location: Hungary - Budapest
Old 08-14-2006 , 05:04   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #6

i've modified c0ldfyr3's makefile, and typed "make ratechecker" instead of "make"
well... ive got this: http://sourcespray.atw.hu/cygwin_err_01.jpg

I guess the main problem is that it doesnt include the header files, therefore it cant find the classes, etc. So..... howto?

Last edited by squeeek; 08-14-2006 at 05:36.
squeeek is offline
Send a message via MSN to squeeek
squeeek
Junior Member
Join Date: Mar 2005
Location: Hungary - Budapest
Old 08-14-2006 , 05:35   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #7

i copied everything from the ratechecker dir to the public dir. i ran the make rateckecker from there, and now i've got so many errormessages, that the window is too small to display them =/
squeeek is offline
Send a message via MSN to squeeek
squeeek
Junior Member
Join Date: Mar 2005
Location: Hungary - Budapest
Old 08-14-2006 , 09:07   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #8

OK, i gave it up.
the linker wont include my "include" dirs "because linking not done", and i get a Segmentation fault error message from cc1plus.

Code:
# (C)2004-2005 SourceMM Development Team
# Makefile originaly written by David "BAILOPAN" Anderson
# Updated by Jay "c0ldfyr3" Croghan www.c0ld.net

#HL2SDL = Path to HL2SDK 		Ex: E:\Coding\c\hl2sdk\
#SMM_ROOT = Path to SourceMM Source 	Ex: E:\Coding\c\sourcemm
#SRCDS = Path to SRCDS binaries. 	Ex: E:\hlds_l

HL2SDK = /cygdrive/e/servercoding/Source
SRCDS = /cygdrive/e/hl2bin
PLUGIN = ratechecker10a

### EDIT BELOW FOR OTHER PROJECTS ###

OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3 -d

# This is the path to the cross compiler.
# Leave it alone ! 
CPP = /opt/crosstool/gcc-3.4.1-glibc-2.3.2/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-gcc
#CPP = /bin/gcc
BINARY = $(PLUGIN)_i486.so

# Add all your cpp files to the following line.
OBJECTS = ratechecker.cpp

#These need to be here.
LINK = vstdlib_i486.so tier0_i486.so

HL2PUB = $(HL2SDK)/public

INCLUDE = -I. -I$(HL2SDK) $(HL2SDK)/public/dlls $(HL2SDK)/public/engine $(HL2SDK)/public/tier0 $(HL2SDK)/public/tier1 \
$(HL2SDK)/public/vstdlib $(HL2SDK)/tier1  $(HL2SDK)/game_shared $(HL2SDK)/dlls \

BIN_DIR = Release
CFLAGS = $(OPT_FLAGS)

CFLAGS += -v -fpermissive -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -fPIC -Wno-deprecated -static-libgcc

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

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

all:
	mkdir -p $(BIN_DIR)
	ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
	ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
	$(MAKE) -d plugin
plugin: $(OBJ_LINUX)
	$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -lm -o$(BIN_DIR)/$(BINARY)

debug:
	$(MAKE) all DEBUG=true

default: all

# clean: 	rm -rf Release/*.o \ rm -rf Release/$(BINARY) \ rm -rf Debug/*.o \ rm -rf Debug/$(BINARY)
I've read everything i've found on the net, but its a bit hard to fix the error with static help... I know you guys can do it ;)
squeeek is offline
Send a message via MSN to squeeek
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 08-14-2006 , 16:31   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #9

You need to add the include directories.

Edit: I see.. you need the -I flag infront of the paths on the INCLUDE makefile variable and not just the first one.
__________________

Last edited by sslice; 08-14-2006 at 16:35.
sslice is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 08-15-2006 , 03:51   Re: Compiling "standard" HL2 plugins with Cygwin
Reply With Quote #10

Code:
# (C)2004-2005 SourceMM Development Team
# Makefile originaly written by David "BAILOPAN" Anderson
# Updated by Jay "c0ldfyr3" Croghan www.c0ld.net

#HL2SDL = Path to HL2SDK 		Ex: E:\Coding\c\hl2sdk\
#SMM_ROOT = Path to SourceMM Source 	Ex: E:\Coding\c\sourcemm
#SRCDS = Path to SRCDS binaries. 	Ex: E:\hlds_l

HL2SDK = /cygdrive/e/servercoding/Source
SRCDS = /cygdrive/e/hl2bin
PLUGIN = ratechecker10a

### EDIT BELOW FOR OTHER PROJECTS ###

OPT_FLAGS = -O3 -fno-rtti -funroll-loops -s -pipe
DEBUG_FLAGS = -g -ggdb3 -d

# This is the path to the cross compiler.
# Leave it alone ! 
CPP = /opt/crosstool/gcc-3.4.1-glibc-2.3.2/i686-unknown-linux-gnu/bin/i686-unknown-linux-gnu-gcc
#CPP = /bin/gcc
BINARY = $(PLUGIN)_i486.so

# Add all your cpp files to the following line.
OBJECTS = ratechecker.cpp

#These need to be here.
LINK = vstdlib_i486.so tier0_i486.so

HL2PUB = $(HL2SDK)/public

INCLUDE = -I. -I$(HL2SDK) -I$(HL2SDK)/public/dlls -I$(HL2SDK)/public/engine -I$(HL2SDK)/public/tier0 -I$(HL2SDK)/public/tier1 \
-I$(HL2SDK)/public/vstdlib -I$(HL2SDK)/tier1  -I$(HL2SDK)/game_shared -I$(HL2SDK)/dlls \

BIN_DIR = Release
CFLAGS = $(OPT_FLAGS)

CFLAGS += -v -fpermissive -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -fPIC -Wno-deprecated -static-libgcc

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

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

all:
	mkdir -p $(BIN_DIR)
	ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so
	ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so
	$(MAKE) -d plugin
plugin: $(OBJ_LINUX)
	$(CPP) $(INCLUDE) $(CFLAGS) $(OBJ_LINUX) $(LINK) -shared -lm -o$(BIN_DIR)/$(BINARY)

debug:
	$(MAKE) all DEBUG=true

default: all

# clean: 	rm -rf Release/*.o \ rm -rf Release/$(BINARY) \ rm -rf Debug/*.o \ rm -rf Debug/$(BINARY)
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode