.96 GCC patch
- Chris
- Posts: 2969
- Joined: Thu Jul 17, 2003 12:07 am
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
.96 GCC patch
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').
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.
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
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.
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.
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.
It still does, I think. At least there is a FLAC folder with code files. But the makefile does not make use of them.rpeter wrote:Anyway, previously the ZDoom source contained everything for FLAC, didn't have to download and build separately anything
You can download the full SDK here: http://www.microsoft.com/downloads/deta ... laylang=enCostja wrote:Where I can download that DirectX headers?
It's nearly 230mb though.
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.).
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.
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.
I think that's because the zdoom.rc isn't processed.Costja wrote:Thanks, All! Now it compiles ZDoom, but the resulting ZDoom.exe hasnt an icon
Ooops, yeah. Didn't notice that, since I always run it from a console anyway. Just add "-mwindows" to the linker options.Costja wrote:and seems to be a console program.
It's using g++ for me...Costja wrote:On the final phase of compiling it requires CC, so I copied GCC with name CC (is it correct?).
I appended -mwindows to the line "LDFLAGS += ..." in the makefile.mingw file, is it correct?boris wrote:Ooops, yeah. Didn't notice that, since I always run it from a console anyway. Just add "-mwindows" to the linker options.Costja wrote:and seems to be a console program.
Now it's using g++ for me too...boris wrote:It's using g++ for me...Costja wrote:On the final phase of compiling it requires CC, so I copied GCC with name CC (is it correct?).
Yes, that's right.Costja wrote: I appended -mwindows to the line "LDFLAGS += ..." in the makefile.mingw file, is it correct?
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

- Chris
- Posts: 2969
- Joined: Thu Jul 17, 2003 12:07 am
- Graphics Processor: ATI/AMD with Vulkan/Metal Support
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.Anyway, previously the ZDoom source contained everything for FLAC.

Can you please give me the command needed to compile it? I'll be able to update the patch if you do.the file src/win32/zdoom.rc has to be compiled into and object file using windres
It's pretty simple:Chris wrote:Can you please give me the command needed to compile it? I'll be able to update the patch if you do.
Code: Select all
windres zdoom.rc zdoomrc.o
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