Raised This Month: $32 Target: $400
 8% 

about compile linux extension problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 12-01-2014 , 04:35   about compile linux extension problem
Reply With Quote #1

Please move to the correct section if I put a incorrect section
I'm new on linux, so try to compile a extension on Ubuntu, but I confuse some problems
also I have read this doc http://wiki.alliedmods.net/building_sourcemod
I think I just don't know how to make file.
so I put the problem here, hope some one can tell me how to make it correctly.

1.when I compile the project with the default settings, the error is:
Code:
CDetour/detours.cpp: In member function ‘bool CDetour::CreateDetour()’:
CDetour/detours.cpp:120:25: error: array subscript is above array bounds [-Werror=array-bounds]
   detour_restore.patch[i] = ((unsigned char *)detour_address)[i];
2.so I try to remove the "-Werror" arg, and then can be compiled.but when the server started. it tell me this message:
Code:
L 12/01/2014 - 01:34:04: [SM] Unable to load extension "dropreason.ext": /home/administrator/Desktop/csgo/csgo/addons/sourcemod/extensions/dropreason.ext.so: undefined symbol: __dynamic_cast
this is my makefile
Code:
# (C)2004-2008 SourceMod Development Team
# Makefile written by David "BAILOPAN" Anderson

SMSDK = ../..
HL2SDK_ORIG = ../../../hl2sdk
HL2SDK_OB = ../../../hl2sdk-ob
HL2SDK_OB_VALVE = ../../../hl2sdk-ob-valve
HL2SDK_L4D = ../../../hl2sdk-l4d
HL2SDK_L4D2 = ../../../hl2sdk-l4d2
HL2SDK_CSGO = ../../../hl2sdk-csgo
MMSOURCE17 = ../../../mmsource-1.10

#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################

PROJECT = dropreason

#Uncomment for Metamod: Source enabled extension
USEMETA = true

OBJECTS = sdk/smsdk_ext.cpp extension.cpp asm/asm.c CDetour/detours.cpp

##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
##############################################

C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = gcc

override ENGSET = false
ifeq "$(ENGINE)" "original"
	HL2SDK = $(HL2SDK_ORIG)
	HL2PUB = $(HL2SDK)/public
	HL2LIB = $(HL2SDK)/linux_sdk
	CFLAGS += -DSOURCE_ENGINE=1
	METAMOD = $(MMSOURCE17)/core-legacy
	INCLUDE += -I$(HL2SDK)/public/dlls -I$(HL2SDK)/game_shared
	GAMEFIX = 1.ep1
	override ENGSET = true
endif
ifeq "$(ENGINE)" "orangebox"
	HL2SDK = $(HL2SDK_OB)
	HL2PUB = $(HL2SDK)/public
	HL2LIB = $(HL2SDK)/lib/linux
	CFLAGS += -DSOURCE_ENGINE=3
	METAMOD = $(MMSOURCE17)/core
	INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework
	GAMEFIX = 2.ep2
	override ENGSET = true
endif
ifeq "$(ENGINE)" "orangeboxvalve"
	HL2SDK = $(HL2SDK_OB_VALVE)
	HL2PUB = $(HL2SDK)/public
	HL2LIB = $(HL2SDK)/lib/linux
	CFLAGS += -DSOURCE_ENGINE=6
	METAMOD = $(MMSOURCE17)/core
	INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework
	GAMEFIX = 2.ep2v
	override ENGSET = true
endif
ifeq "$(ENGINE)" "left4dead"
	HL2SDK = $(HL2SDK_L4D)
	HL2PUB = $(HL2SDK)/public
	HL2LIB = $(HL2SDK)/lib/linux
	CFLAGS += -DSOURCE_ENGINE=7
	METAMOD = $(MMSOURCE17)/core
	INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework
	GAMEFIX = 2.l4d
	override ENGSET = true
endif
ifeq "$(ENGINE)" "left4dead2"
	HL2SDK = $(HL2SDK_L4D2)
	HL2PUB = $(HL2SDK)/public
	HL2LIB = $(HL2SDK)/lib/linux
	CFLAGS += -DSOURCE_ENGINE=8
	METAMOD = $(MMSOURCE17)/core
	INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework
	GAMEFIX = 2.l4d2
	override ENGSET = true
endif
ifeq "$(ENGINE)" "csgo"
	HL2SDK = $(HL2SDK_CSGO)
	HL2PUB = $(HL2SDK)/public
	HL2LIB = $(HL2SDK)/lib/linux
	CFLAGS += -DSOURCE_ENGINE=11
	METAMOD = $(MMSOURCE17)/core
	INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared -I$(HL2SDK)/public/toolframework
	GAMEFIX = 2.csgo
	override ENGSET = true
endif

ifeq ($(ENGINE),$(filter $(ENGINE), csgo left4dead2 orangeboxvalve))
	LINK_HL2 = $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a libvstdlib.so libtier0.so
else
	LINK_HL2 = $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a vstdlib_i486.so tier0_i486.so
endif

ifeq "$(ENGINE)" "csgo"
	LINK_HL2 += $(HL2LIB)/interfaces_i486.a
endif

LINK += $(LINK_HL2)

INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/tier0 \
	-I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/extensions \
	-I$(SMSDK)/public/sourcepawn

CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \
	-DSE_ORANGEBOXVALVE=6 -DSE_LEFT4DEAD=7 -DSE_LEFT4DEAD2=8 -DSE_ALIENSWARM=9 -DSE_PORTAL2=10 \
	-DSE_CSGO=11

LINK += -m32 -ldl -lm

CFLAGS += -D_LINUX -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
	-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -DCOMPILER_GCC \
	-Wno-switch -Wall -Werror -Wno-uninitialized -Wno-invalid-offsetof -Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti -fno-threadsafe-statics

################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
################################################

ifeq "$(DEBUG)" "true"
	BIN_DIR = Debug
	CFLAGS += $(C_DEBUG_FLAGS)
else
	BIN_DIR = Release
	CFLAGS += $(C_OPT_FLAGS)
endif

ifeq "$(USEMETA)" "true"
	BIN_DIR := $(BIN_DIR).$(ENGINE)
endif

OS := $(shell uname -s)
ifeq "$(OS)" "Darwin"
	LINK += -dynamiclib
	BINARY = $(PROJECT).ext.$(GAMEFIX).dylib
else
	LINK += -static-libgcc -shared
	BINARY = $(PROJECT).ext.$(GAMEFIX).so
endif

GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
ifeq "$(GCC_VERSION)" "4"
	CFLAGS += $(C_GCC4_FLAGS)
	CPPFLAGS += $(CPP_GCC4_FLAGS)
endif

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

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

all: check
	mkdir -p $(BIN_DIR)/sdk
	mkdir -p $(BIN_DIR)/CDetour
	mkdir -p $(BIN_DIR)/asm
ifeq ($(ENGINE),$(filter $(ENGINE), csgo left4dead2 orangeboxvalve))
	ln -sf $(HL2LIB)/libvstdlib.so libvstdlib.so;
	ln -sf $(HL2LIB)/libtier0.so libtier0.so;
else
	ln -sf $(HL2LIB)/vstdlib_i486.so vstdlib_i486.so;
	ln -sf $(HL2LIB)/tier0_i486.so tier0_i486.so;
endif
	$(MAKE) -f Makefile extension

check:
	if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \
		echo "You must supply ENGINE=left4dead or ENGINE=orangebox or ENGINE=original"; \
		exit 1; \
	fi

extension: check $(OBJ_LINUX)
	$(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY)

debug:
	$(MAKE) -f Makefile all DEBUG=true

default: all

clean: check
	rm -rf $(BIN_DIR)/*.o
	rm -rf $(BIN_DIR)/sdk/*.o
	rm -rf $(BIN_DIR)/CDetour/*.o
	rm -rf $(BIN_DIR)/asm/*.o
	rm -rf $(BIN_DIR)/$(BINARY)
hope some one can help me ! thx !
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-01-2014 , 07:03   Re: about compile linux extension problem
Reply With Quote #2

https://github.com/powerlord/sourcem.../sourcemod-1.6
set up the AMBuilder file for your extension
__________________
WildCard65 is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-01-2014 , 11:50   Re: about compile linux extension problem
Reply With Quote #3

For CS:GO on linux, as of a few months ago, you now need to link stdlibc++ (-lstdc++ or use g++/clang++ instead of gcc/clang).
psychonic is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-01-2014 , 17:02   Re: about compile linux extension problem
Reply With Quote #4

To add to what psychonic and WildCard65 said... the sourcemod-sampleext stuff in my repo was written WAY back when SM 1.6 was still in early development. It really needs an update, particularly the AMBuild stuff (which is AMBuild 1.x)
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 12-01-2014 , 22:06   Re: about compile linux extension problem
Reply With Quote #5

thanks for your replies, and I have started to learn how to write a ambuild script.
@Powerlord by the way, I think it will be better that update you sample script when you are free ;), it will be nice for that guy who are the new on ambuild .
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 12-04-2014 , 01:03   Re: about compile linux extension problem
Reply With Quote #6

I still got the problem when I try to compile the mmsource and the sourcemod with local,
also the source of the mmsource and sourcemod are download from github
mmsource:https://github.com/alliedmodders/met...-1.10.4.tar.gz
sourcemod:https://github.com/alliedmodders/sou...d-1.6.3.tar.gz

sourcemod error:
Code:
[4884] c++ -pipe -fno-strict-aliasing -Wall -Werror -Wno-uninitialized -Wno-unused -Wno-switch -Wno-format -Wno-format-security -msse -m32 -fvisibility=hidden -Wno-narrowing -mfpmath=sse -O3 -g3 -ggdb3 -fvisibility-inlines-hidden -Wno-delete-non-virtual-dtor -fno-exceptions -fno-threadsafe-statics -Wno-non-virtual-dtor -Wno-overloaded-virtual -fno-rtti -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -DHAVE_STDINT_H -DGNUC -DNDEBUG -D_LINUX -DPOSIX -DSOURCEMOD_BUILD -DSM_USE_VERSIONLIB -DSM_GENERATED_BUILD -I /home/administrator/Desktop/alliedmodders/sourcemod/build/includes -I /home/administrator/Desktop/alliedmodders/sourcemod/versionlib -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/core/sourcehook -I /home/administrator/Desktop/alliedmodders/sourcemod/sourcepawn/jit -I /home/administrator/Desktop/alliedmodders/sourcemod/sourcepawn/jit/x86 -I /home/administrator/Desktop/alliedmodders/sourcemod/public -I /home/administrator/Desktop/alliedmodders/sourcemod/public/sourcepawn -I /home/administrator/Desktop/alliedmodders/sourcemod/public/amtl -I /home/administrator/Desktop/alliedmodders/sourcemod/public/jit -I /home/administrator/Desktop/alliedmodders/sourcemod/public/jit/x86 -I /home/administrator/Desktop/alliedmodders/sourcemod/knight/shared -H -c /home/administrator/Desktop/alliedmodders/sourcemod/sourcepawn/jit/engine2.cpp -o engine2.o
/home/administrator/Desktop/alliedmodders/sourcemod/sourcepawn/jit/engine2.cpp: In member function ‘virtual SourcePawn::IPluginRuntime* SourcePawn::SourcePawnEngine2::LoadPlugin(SourcePawn::ICompilation*, const char*, int*)’:
/home/administrator/Desktop/alliedmodders/sourcemod/sourcepawn/jit/engine2.cpp:38:43: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Werror=unused-result]
  fread(&hdr, sizeof(sp_file_hdr_t), 1, fp);
                                           ^
/home/administrator/Desktop/alliedmodders/sourcemod/sourcepawn/jit/engine2.cpp:59:38: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Werror=unused-result]
    fread(sectheader, sectsize, 1, fp);
                                      ^
/home/administrator/Desktop/alliedmodders/sourcemod/sourcepawn/jit/engine2.cpp:60:35: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Werror=unused-result]
    fread(tempbuf, compsize, 1, fp);
                                   ^
/home/administrator/Desktop/alliedmodders/sourcemod/sourcepawn/jit/engine2.cpp:84:37: error: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result [-Werror=unused-result]
    fread(base, hdr.imagesize, 1, fp);
                                     ^
cc1plus: all warnings being treated as errors
mmsource error:
Code:
[4215] c++ -pipe -fno-strict-aliasing -Wall -Werror -Wno-uninitialized -Wno-unused -Wno-switch -msse -m32 -fvisibility=hidden -mfpmath=sse -O3 -g3 -ggdb3 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-threadsafe-statics -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-delete-non-virtual-dtor -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -DHAVE_STDINT_H -DGNUC -DNDEBUG -D_LINUX -DPOSIX -DMMS_GENERATED_BUILD -DSE_CSGO=19 -DSOURCE_ENGINE=19 -DCOMPILER_GCC -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/build/includes -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/versionlib -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/public -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/core -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/core/sourcehook -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/loader -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/public -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/public/engine -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/public/mathlib -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/public/vstdlib -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/public/tier0 -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/public/tier1 -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/public/game/server -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/game/shared -I /home/administrator/Desktop/alliedmodders/hl2sdk-csgo/common -H -c /home/administrator/Desktop/alliedmodders/mmsource-1.10/core/metamod.cpp -o metamod.o
/home/administrator/Desktop/alliedmodders/mmsource-1.10/core/metamod.cpp: In function ‘void InitializeVSP()’:
/home/administrator/Desktop/alliedmodders/mmsource-1.10/core/metamod.cpp:326:35: error: ignoring return value of ‘char* realpath(const char*, char*)’, declared with attribute warn_unused_result [-Werror=unused-result]
  abspath(engine_path, engine_file);
                                   ^
cc1plus: all warnings being treated as errors
[4216] c++ -pipe -fno-strict-aliasing -Wall -Werror -Wno-uninitialized -Wno-unused -Wno-switch -msse -m32 -fvisibility=hidden -mfpmath=sse -O3 -g3 -ggdb3 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fno-threadsafe-statics -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-delete-non-virtual-dtor -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -DHAVE_STDINT_H -DGNUC -DNDEBUG -D_LINUX -DPOSIX -DMMS_GENERATED_BUILD -DLIB_PREFIX="" -DLIB_SUFFIX="_i486.so" -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/build/includes -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/versionlib -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/public -I /home/administrator/Desktop/alliedmodders/mmsource-1.10/core/sourcehook -H -c /home/administrator/Desktop/alliedmodders/mmsource-1.10/loader/gamedll.cpp -o gamedll.o
/home/administrator/Desktop/alliedmodders/mmsource-1.10/loader/gamedll.cpp: In function ‘bool mm_DetectGameInformation()’:
/home/administrator/Desktop/alliedmodders/mmsource-1.10/loader/gamedll.cpp:99:36: error: ignoring return value of ‘char* getcwd(char*, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result]
  getcwd(cur_path, sizeof(cur_path));
                                    ^
cc1plus: all warnings being treated as errors
did I have to remove "-Werror" arg ?

compile the debug version is success. but the release version is failed !
my command line is
Code:
python ../configure.py -s csgo --enable-optimize
ambuild
anything did I lose ?
__________________
QQ:116268742

Last edited by K.K.Lv; 12-04-2014 at 01:06.
K.K.Lv is offline
Send a message via MSN to K.K.Lv
psychonic

BAFFLED
Join Date: May 2008
Old 12-04-2014 , 07:36   Re: about compile linux extension problem
Reply With Quote #7

We use Clang to compile the official builds. If you want to do a manual build with GCC, it looks like you need to add -Wno-unused-result. I'd be happy to review a pull request that either adds that if GCC is being used or fixes the warnings if they're harmful.
psychonic is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 12-04-2014 , 08:57   Re: about compile linux extension problem
Reply With Quote #8

@psychonic and I have fixed the warning as you said, anyway thx, maybe I have to try to fixed the error by myself before post the thread on the forum ;)
and now I think I know how to make a good AMBuildScript !
and I hope the next official version script will fixed that problem !
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Reply


Thread Tools
Display Modes

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 04:49.


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