.96 GCC patch

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
User avatar
Chris
Posts: 2969
Joined: Thu Jul 17, 2003 12:07 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

.96 GCC patch

Post by Chris »

This patch should allow GCC (Linux and MinGW, at least) to compile ZDoom. For Linux, you'll need: NASM, GCC 3.3 (3.4 does work, but it seems only when OPTLEVEL is set to 1), SDL, FLAC, FMOD, and zlib. For MinGW you'll need UnixUtils, NASM, FLAC, FMOD, and zlib (along with a recent DX SDK?).

Extract the archive in the same place you did the source, run 'patch -p0 < changes.diff' to patch the source, and use the proper makefile (either by copying/renaming it to 'makefile' or passing the -f switch to make). If all goes well, you should have ZDoom built

On the command line, you can set OPTLEVEL to what you want to pass to the -O switch, and ARCH_TYPE for what you want to pass to -march=. OPTLEVEL=2 and ARCH_TYPE=pentium are the defaults.

The archive also contains an snesapu.diff for Linux users who want to get the SNESAPU source compiled as a dynamic/shared lib. The produced .so will work with the patched C++ example and ZDoom as long as the lib is installed in the library search path.

Update #1: Updated the makefiles. New option: setting NOASM=1 on the command line should disable ASM.

Update #2: The .rc file gets properly used and compiled for MinGW now.

Update #3: Fixed the Linux makefile which broke in the last version (the object file list was being overwritten). Also renamed the debug exe to zdoom-debug, and the MinGW release exe to zdoomgcc (Linux release is still plain 'zdoom').
Last edited by Chris on Sat Jan 08, 2005 8:12 pm, edited 5 times in total.
Costja
Posts: 188
Joined: Mon Oct 18, 2004 3:58 pm
Location: Russia, Moscow
Contact:

Post by Costja »

Using this patch and MinGW I cant compile ZDoom nor with FLAC from a ZDoom .96 source package nor with FLAC from a flac-1.1.1-devel-win.zip archive:

Code: Select all

...
obj/i_crash.o obj/i_movie.o obj/win32video.o obj/autozend.o -lFLAC++ -lFLAC -lfmod -lz -lwsock32 -lwinmm -ldsound -ldxguid -ldinput8 -lole32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32
Warning: .drectve `%.*s' unrecognized
Warning: .drectve `%.*s' unrecognized
Warning: .drectve `%.*s' unrecognized
Warning: .drectve `%.*s' unrecognized
obj/music_flac.o(.text+0x547):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::Stream()'
obj/music_flac.o(.text+0x5d2):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::init()'
obj/music_flac.o(.text+0x5dd):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::process_until_end_of_metadata()'
obj/music_flac.o(.text+0x63b):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/music_flac.o(.text+0x6a7):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::Stream()'
obj/music_flac.o(.text+0x732):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::init()'
obj/music_flac.o(.text+0x73d):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::process_until_end_of_metadata()'
obj/music_flac.o(.text+0x79b):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/music_flac.o(.text+0x7f6):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/music_flac.o(.text+0x856):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/music_flac.o(.text+0x8b6):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/music_flac.o(.text+0x96a):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::get_state() const'
obj/music_flac.o(.text+0x97b):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::process_single()'
obj/music_flac.o(.text+0x9ae):music_flac.cpp: undefined reference to `FLAC::Decoder::Stream::reset()'
obj/sample_flac.o(.text+0x4a):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::Stream()'
obj/sample_flac.o(.text+0x118):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::init()'
obj/sample_flac.o(.text+0x126):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::process_until_end_of_metadata()'
obj/sample_flac.o(.text+0x183):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/sample_flac.o(.text+0x1ea):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::Stream()'
obj/sample_flac.o(.text+0x2b8):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::init()'
obj/sample_flac.o(.text+0x2c6):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::process_until_end_of_metadata()'
obj/sample_flac.o(.text+0x323):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/sample_flac.o(.text+0x48c):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::process_until_end_of_stream()'
obj/sample_flac.o(.text+0x5d3):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::process_until_end_of_stream()'
obj/sample_flac.o(.text+0x62b):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/sample_flac.o(.text+0x65b):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/sample_flac.o(.text+0x68b):sample_flac.cpp: undefined reference to `FLAC::Decoder::Stream::~Stream()'
obj/i_input.o(.text+0x2ac1):i_input.cpp: undefined reference to `IID_IDirectInput8A'
obj/i_input.o(.text+0x2acc):i_input.cpp: undefined reference to `CLSID_DirectInput8'
c:\gnu\mingw\bin\mingw32-make.exe: *** [zdoom] Error 1
boris
Posts: 773
Joined: Tue Jul 15, 2003 3:37 pm

Post by boris »

Hmm, I downloaded the FLAC source and compiled it myself (UNIX-style with MSYS). It failed compiling some of the examples (or something), but built the lib files without a problem. I just had to move them to my MinGW dir on my own.
rpeter
Posts: 150
Joined: Mon Jul 21, 2003 10:52 pm

Post by rpeter »

You start to get me into compiling mood again.

Anyway, previously the ZDoom source contained everything for FLAC, didn't have to download and build separately anything, not counting the asm stuff ( I stick to NOASM, I got a fast enough machine and I got burned by nasm before: Duke ).

For DirectX: only 3 or 4 header files were needed ( dsound.h, dinput.h, ddraw.h, ? ).
The movie stuff will never work, it's not using _stdcall, but some MS WABI.

Optimization: gcc traditionally has bugs optimizing inlines. I had a nightmare porting Duke to MinGW, I could only switch on any optimization after I removed all inlines and turned the nasm code to plain C. And when I see optimize off pragmas in MS VC projects I know gcc may burn me.
Costja
Posts: 188
Joined: Mon Oct 18, 2004 3:58 pm
Location: Russia, Moscow
Contact:

Post by Costja »

Thanks, now it compiles the FLAC part.

Where I can download that DirectX headers?
boris
Posts: 773
Joined: Tue Jul 15, 2003 3:37 pm

Post by boris »

rpeter wrote:Anyway, previously the ZDoom source contained everything for FLAC, didn't have to download and build separately anything
It still does, I think. At least there is a FLAC folder with code files. But the makefile does not make use of them.
Costja wrote:Where I can download that DirectX headers?
You can download the full SDK here: http://www.microsoft.com/downloads/deta ... laylang=en
It's nearly 230mb though.
Costja
Posts: 188
Joined: Mon Oct 18, 2004 3:58 pm
Location: Russia, Moscow
Contact:

Post by Costja »

I'm downloading DirectX SDK now but it's too big and I need that headers only for ZDoom.
rpeter
Posts: 150
Joined: Mon Jul 21, 2003 10:52 pm

Post by rpeter »

It's not only big, it's also useless for MinGW. You need DirectX headers specifically modified ( actually, recreated to satisfy the lawyers ) for MinGW. Google up something like DirectX 8 for MinGW, it should only be just around 2 MByte. And what you need is only the 3 header files, MinGW already contains the DirectX libraries (libdsound.a, libdinput.a, libddraw.a, libdxguid.a, etc.).
boris
Posts: 773
Joined: Tue Jul 15, 2003 3:37 pm

Post by boris »

Something like this? http://alleg.sourceforge.net/files/dx80_mgw.zip
That's what you need to compile Allegro for Windows. But it seems to include all DirectX libs and headers, it's about 2.7mb zipped.
Costja
Posts: 188
Joined: Mon Oct 18, 2004 3:58 pm
Location: Russia, Moscow
Contact:

Post by Costja »

Thanks, All! Now it compiles ZDoom, but the resulting ZDoom.exe hasnt an icon and seems to be a console program.
On the final phase of compiling it requires CC, so I copied GCC with name CC (is it correct?).
boris
Posts: 773
Joined: Tue Jul 15, 2003 3:37 pm

Post by boris »

Costja wrote:Thanks, All! Now it compiles ZDoom, but the resulting ZDoom.exe hasnt an icon
I think that's because the zdoom.rc isn't processed.
Costja wrote:and seems to be a console program.
Ooops, yeah. Didn't notice that, since I always run it from a console anyway. Just add "-mwindows" to the linker options.
Costja wrote:On the final phase of compiling it requires CC, so I copied GCC with name CC (is it correct?).
It's using g++ for me...
Costja
Posts: 188
Joined: Mon Oct 18, 2004 3:58 pm
Location: Russia, Moscow
Contact:

Post by Costja »

boris wrote:
Costja wrote:and seems to be a console program.
Ooops, yeah. Didn't notice that, since I always run it from a console anyway. Just add "-mwindows" to the linker options.
I appended -mwindows to the line "LDFLAGS += ..." in the makefile.mingw file, is it correct?
boris wrote:
Costja wrote:On the final phase of compiling it requires CC, so I copied GCC with name CC (is it correct?).
It's using g++ for me...
Now it's using g++ for me too...
boris
Posts: 773
Joined: Tue Jul 15, 2003 3:37 pm

Post by boris »

Costja wrote: I appended -mwindows to the line "LDFLAGS += ..." in the makefile.mingw file, is it correct?
Yes, that's right.

As for the .exe not having an icon... the file src/win32/zdoom.rc has to be compiled into and object file using windres. The compiled .rc can then be normally linked with the other files, and voilà, zdoom.exe will have the Doom marine icon ;) I'm not too good with makefiles, but it should be possible to incorporate that step in there.
User avatar
Chris
Posts: 2969
Joined: Thu Jul 17, 2003 12:07 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Post by Chris »

Anyway, previously the ZDoom source contained everything for FLAC.
The problem is, MinGW has no way to detect if FLAC is already installed or not, and since it's probably compiled as a DLL (and linking with the DLL is quite preferred for ease of upgradeing and reducing .exe size), it's recommened to get the official packages and build them. PS. if the DLLs (for FLAC or zlib) use a different name or require a define before including the headers or something, please let me know. :)
the file src/win32/zdoom.rc has to be compiled into and object file using windres
Can you please give me the command needed to compile it? I'll be able to update the patch if you do.
boris
Posts: 773
Joined: Tue Jul 15, 2003 3:37 pm

Post by boris »

Chris wrote:Can you please give me the command needed to compile it? I'll be able to update the patch if you do.
It's pretty simple:

Code: Select all

windres zdoom.rc zdoomrc.o

or, if you like a lot command line parameters

Code: Select all

windres -i zdoom.rc -o zdoomrc.o


[edit]
BTW, IIRC -mwindows is deprecated, and you're supposed to use the following instead:

Code: Select all

-Wl,--subsystem,windows

Post Reply

Return to “General”