View Single Post
Re: Compiling dlls with MingWing
Old
  (#4)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Compiling dlls with MingWing - 06-03-2005

"And you did mean to change the gcc to g++ in the CC section at the beginning, right?"

No. I mean that use g++ to compile .cpp files, and use gcc to compile C files.
my makefile for HLSDK is like this:
PHP Code:
#
# Half-Life Full SDK 2.2 Makefile for MinGW
#
# March 2002 by botman (botman@planethalflife.com)
# Modified by Wei Mingzhi (whistler_wmz@users.sf.net)
#

# this is the name of your game MOD DLL file...
DLLNAME=hl

# make sure this is the correct compiler for your system
CC=gcc
CPP
=g++

DLL_SRCDIR=.
ENGINE_SRCDIR=../engine
COMMON_SRCDIR
=../common
WPN_SHARED_SRCDIR
=./wpn_shared
PM_SHARED_SRCDIR
=../pm_shared
GAME_SHARED_SRCDIR
=../game_shared

MAIN_OBJDIR
=$(DLL_SRCDIR)/obj
DLL_OBJDIR
=$(DLL_SRCDIR)/obj/dll
WPN_SHARED_OBJDIR
=$(DLL_SRCDIR)/obj/wpn_shared
PM_SHARED_OBJDIR
=$(DLL_SRCDIR)/obj/pm_shared
GAME_SHARED_OBJDIR
=$(DLL_SRCDIR)/obj/game_shared

BASE_CFLAGS
=-DCLIENT_WEAPONS

CFLAGS
=$(BASE_CFLAGS) --march=i486 -O2

# use these when debugging...
#CFLAGS=$(BASE_CFLAGS) -g

INCLUDEDIRS=-I. -I$(ENGINE_SRCDIR) -I$(COMMON_SRCDIR) -I$(PM_SHARED_SRCDIR) -I$(GAME_SHARED_SRCDIR)

# normal linker flags...
LDFLAGS=-s

# use these when debugging...
#LDFLAGS=

DO_CC=$(CC) $(CFLAGS) $(INCLUDEDIRS) -$@ -$<
DO_CPP=$(CPP) $(CFLAGS) $(INCLUDEDIRS) -$@ -$<

#############################################################################
# SETUP AND BUILD
# GAME
#############################################################################

$(DLL_OBJDIR)/%.o: $(DLL_SRCDIR)/%.cpp
    
$(DO_CPP)

$(
WPN_SHARED_OBJDIR)/%.o: $(WPN_SHARED_SRCDIR)/%.cpp
    
$(DO_CPP)

$(
GAME_SHARED_OBJDIR)/%.o: $(GAME_SHARED_SRCDIR)/%.cpp
    
$(DO_CPP)

$(
PM_SHARED_OBJDIR)/%.o: $(PM_SHARED_SRCDIR)/%.c
    
$(DO_CC)

OBJ = \
    $(
DLL_OBJDIR)/aflock.\
    $(
DLL_OBJDIR)/agrunt.\
    $(
DLL_OBJDIR)/airtank.\
    $(
DLL_OBJDIR)/animating.\
    $(
DLL_OBJDIR)/animation.\
    $(
DLL_OBJDIR)/apache.\
    $(
DLL_OBJDIR)/barnacle.\
    $(
DLL_OBJDIR)/barney.\
    $(
DLL_OBJDIR)/bigmomma.\
    $(
DLL_OBJDIR)/bloater.\
    $(
DLL_OBJDIR)/bmodels.\
    $(
DLL_OBJDIR)/bullsquid.\
    $(
DLL_OBJDIR)/buttons.\
    $(
DLL_OBJDIR)/cbase.\
    $(
DLL_OBJDIR)/client.\
    $(
DLL_OBJDIR)/combat.\
    $(
DLL_OBJDIR)/controller.\
    $(
DLL_OBJDIR)/crossbow.\
    $(
DLL_OBJDIR)/crowbar.\
    $(
DLL_OBJDIR)/defaultai.\
    $(
DLL_OBJDIR)/doors.\
    $(
DLL_OBJDIR)/effects.\
    $(
DLL_OBJDIR)/egon.\
    $(
DLL_OBJDIR)/explode.\
    $(
DLL_OBJDIR)/flyingmonster.\
    $(
DLL_OBJDIR)/func_break.\
    $(
DLL_OBJDIR)/func_tank.\
    $(
DLL_OBJDIR)/game.\
    $(
DLL_OBJDIR)/gamerules.\
    $(
DLL_OBJDIR)/gargantua.\
    $(
DLL_OBJDIR)/gauss.\
    $(
DLL_OBJDIR)/genericmonster.\
    $(
DLL_OBJDIR)/ggrenade.\
    $(
DLL_OBJDIR)/globals.\
    $(
DLL_OBJDIR)/gman.\
    $(
DLL_OBJDIR)/h_ai.\
    $(
DLL_OBJDIR)/h_battery.\
    $(
DLL_OBJDIR)/h_cine.\
    $(
DLL_OBJDIR)/h_cycler.\
    $(
DLL_OBJDIR)/h_export.\
    $(
DLL_OBJDIR)/handgrenade.\
    $(
DLL_OBJDIR)/hassassin.\
    $(
DLL_OBJDIR)/headcrab.\
    $(
DLL_OBJDIR)/healthkit.\
    $(
DLL_OBJDIR)/hgrunt.\
    $(
DLL_OBJDIR)/hornet.\
    $(
DLL_OBJDIR)/hornetgun.\
    $(
DLL_OBJDIR)/houndeye.\
    $(
DLL_OBJDIR)/ichthyosaur.\
    $(
DLL_OBJDIR)/islave.\
    $(
DLL_OBJDIR)/items.\
    $(
DLL_OBJDIR)/leech.\
    $(
DLL_OBJDIR)/lights.\
    $(
DLL_OBJDIR)/maprules.\
    $(
DLL_OBJDIR)/monstermaker.\
    $(
DLL_OBJDIR)/monsters.\
    $(
DLL_OBJDIR)/monsterstate.\
    $(
DLL_OBJDIR)/mortar.\
    $(
DLL_OBJDIR)/mp5.\
    $(
DLL_OBJDIR)/multiplay_gamerules.\
    $(
DLL_OBJDIR)/namefunc.\
    $(
DLL_OBJDIR)/nihilanth.\
    $(
DLL_OBJDIR)/nodes.\
    $(
DLL_OBJDIR)/osprey.\
    $(
DLL_OBJDIR)/pathcorner.\
    $(
DLL_OBJDIR)/plane.\
    $(
DLL_OBJDIR)/plats.\
    $(
DLL_OBJDIR)/player.\
    $(
DLL_OBJDIR)/python.\
    $(
DLL_OBJDIR)/rat.\
    $(
DLL_OBJDIR)/roach.\
    $(
DLL_OBJDIR)/rpg.\
    $(
DLL_OBJDIR)/satchel.\
    $(
DLL_OBJDIR)/schedule.\
    $(
DLL_OBJDIR)/scientist.\
    $(
DLL_OBJDIR)/scripted.\
    $(
DLL_OBJDIR)/shotgun.\
    $(
DLL_OBJDIR)/singleplay_gamerules.\
    $(
DLL_OBJDIR)/skill.\
    $(
DLL_OBJDIR)/sound.\
    $(
DLL_OBJDIR)/soundent.\
    $(
DLL_OBJDIR)/spectator.\
    $(
DLL_OBJDIR)/squadmonster.\
    $(
DLL_OBJDIR)/squeakgrenade.\
    $(
DLL_OBJDIR)/subs.\
    $(
DLL_OBJDIR)/talkmonster.\
    $(
DLL_OBJDIR)/teamplay_gamerules.\
    $(
DLL_OBJDIR)/tempmonster.\
    $(
DLL_OBJDIR)/tentacle.\
    $(
DLL_OBJDIR)/triggers.\
    $(
DLL_OBJDIR)/tripmine.\
    $(
DLL_OBJDIR)/turret.\
    $(
DLL_OBJDIR)/util.\
    $(
DLL_OBJDIR)/weapons.\
    $(
DLL_OBJDIR)/world.\
    $(
DLL_OBJDIR)/xen.\
    $(
DLL_OBJDIR)/zombie.\
    $(
WPN_SHARED_OBJDIR)/hl_wpn_glock.\
    $(
GAME_SHARED_OBJDIR)/voice_gamemgr.\
    $(
PM_SHARED_OBJDIR)/pm_debug.\
    $(
PM_SHARED_OBJDIR)/pm_math.\
    $(
PM_SHARED_OBJDIR)/pm_shared.o

all
:    $(MAIN_OBJDIR)/$(DLLNAME).dll

$(MAIN_OBJDIR)/$(DLLNAME).dll:    $(DLL_OBJDIR)/dir $(WPN_SHARED_OBJDIR)/dir \
    $(
GAME_SHARED_OBJDIR)/dir $(PM_SHARED_OBJDIR)/dir $(OBJ)
    
dllwrap $(LDFLAGS) --add-stdcall-alias --driver-name=$(CPP) -$(MAIN_OBJDIR)/$(DLLNAME).dll $(OBJ)

$(
MAIN_OBJDIR)/dir:
    -
mkdir $(MAIN_OBJDIR)
    -@echo 
dir >$(MAIN_OBJDIR)/dir

$(DLL_OBJDIR)/dir: $(MAIN_OBJDIR)/dir
    
-mkdir $(DLL_OBJDIR)
    -@echo 
dir >$(DLL_OBJDIR)/dir

$(WPN_SHARED_OBJDIR)/dir: $(MAIN_OBJDIR)/dir
    
-mkdir $(WPN_SHARED_OBJDIR)
    -@echo 
dir >$(WPN_SHARED_OBJDIR)/dir

$(GAME_SHARED_OBJDIR)/dir: $(MAIN_OBJDIR)/dir
    
-mkdir $(GAME_SHARED_OBJDIR)
    -@echo 
dir >$(GAME_SHARED_OBJDIR)/dir

$(PM_SHARED_OBJDIR)/dir: $(MAIN_OBJDIR)/dir
    
-mkdir $(PM_SHARED_OBJDIR)
    -@echo 
dir >$(PM_SHARED_OBJDIR)/dir

clean
:
    -
rm $(DLL_OBJDIR)/*.o
    -rm $(WPN_SHARED_OBJDIR)/*.o
    -rm $(GAME_SHARED_OBJDIR)/*.o
    -rm $(PM_SHARED_OBJDIR)/*.o
    -rm $(MAIN_OBJDIR)/$(DLLNAME).dll 
also if you can't use "make" command, use "mingw32-make" instead.

Last edited by Whistler; 06-03-2005 at 08:28..
  
Reply With Quote