Coder Social home page Coder Social logo

Compilation with MinGW about berserkerquake2 HOT 4 OPEN

UCyborg avatar UCyborg commented on September 28, 2024
Compilation with MinGW

from berserkerquake2.

Comments (4)

hgdagon avatar hgdagon commented on September 28, 2024

I was messing around just for myself, but, maybe, you can use this as a starting point.

Or, if you don't want to download:
I added #include <errno.h> to both main.c and game.c.
Converted both Berserker.rc and resource.h to UTF-8 (also converted EOL to LF).
Replaced winres.h in Berserker.rc with windows.h.
And here's my Makefile.mingw:

CC=gcc
WINDRES=windres

CFLAGS=-w -O3 -fno-strict-aliasing -DNDEBUG

LDFLAGS_ENGINE=-lopengl32 -lvorbis -lvorbisfile -lz -lminizip -lws2_32 -lmingw32 -lSDL2Main -lSDL2 -lpng -ljpeg
LDFLAGS_GAME=-shared -fPIC

ENGINE_SOURCES=main.c unpak.c
GAME_SOURCES=game.c

ENGINE_OBJECTS=$(ENGINE_SOURCES:.c=.o)
GAME_OBJECTS=$(GAME_SOURCES:.c=.o)

ENGINE_EXE=berserkerq2.exe
GAME_LIB=game.dll
ICON = Berserker/Berserker.rc
ICONRES = Berserker/Berserker.res

all: $(ENGINE_EXE) $(GAME_LIB)

$(ENGINE_OBJECTS): %.o : %.c
	$(CC) $(CFLAGS) -c $< -o $@

$(GAME_OBJECTS): %.o : %.c
	$(CC) $(CFLAGS) -fPIC -fvisibility=hidden -c $< -o $@

$(ENGINE_EXE): $(ENGINE_OBJECTS) $(ICONRES)
	$(CC) -o $@ $^ $(LDFLAGS_ENGINE)

$(GAME_LIB): $(GAME_OBJECTS)
	$(CC) -o $@ $(GAME_OBJECTS) $(LDFLAGS_GAME)

$(ICONRES): $(ICON)
	$(WINDRES) $^ -O coff -o $@

clean:
	-rm $(ENGINE_EXE) $(GAME_LIB) $(ENGINE_OBJECTS) $(GAME_OBJECTS) $(ICONRES)

When I actually got to testing, I realized

my current laptop royally sucks (and my main laptop is unavailable).
So, I can only confirm, that this builds (in both MinGW and MinGW-W64), launches, caches everything (AFTER cranking up the hunksize), and starts the first map. No idea how it actually behaves in-game, though. I use msys2.

BerserkerQuake2-msys2-wip.zip

from berserkerquake2.

UCyborg avatar UCyborg commented on September 28, 2024

You got further than me. I messed with this some time ago and the errno.h was the easy part. I somehow ended up with .exe that just crashed on startup.

Didn't use msys2 at the time, this might be the key. I find compiling with MinGW interesting because you supposedly end up with binaries that link against good old msvcrt.dll, rather than newer runtimes.

I only used pacman briefly when I wanted to get Berserker compiled and running on Manjaro. It was pretty straightforward, thought I'd be more difficult. So I assume with msys2, you can get dev files as well as pre-compiled binaries? I ask because when I was searching the internet for binaries of dependent libraries, I only found SDL2 and zlib.

Thank you for your this. I'll look into it further when I find more time.

from berserkerquake2.

hgdagon avatar hgdagon commented on September 28, 2024

@UCyborg You don't need to search the internet, msys2 has it's own repos and comes with pacman. And yes, pretty much every package contains libraries, headers, as well as binaries. If the package you need is not in the repos, you can always (try to) compile from source yourself.

from berserkerquake2.

UCyborg avatar UCyborg commented on September 28, 2024

Good to know. When I get to it, I'll try to make another release compiled exclusively with with Windows version of gcc. The pre-compiled libraries should make this easier. The ZIP file in the Releases section contains 99% of the things compiled with MSVC, except the SDL2 library, which I had problems compiling on my own... It might have needed extra stuff from DirectX SDK June 2010 release to get SDL2 binary with all features, not sure. Some of the DX headers and libraries are definitely included in the current SDKs you get with Visual Studio.

There's also Visual Studio way of managing packages, NuGet, but at the time, I didn't find every package needed. Another project, dhewm3, has those includes and libs in a separate repo. As these things are only here for Windows compiling and redundant for non-Windows systems...

from berserkerquake2.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.