View Issue Details

IDProjectCategoryView StatusLast Update
0004198The Dark ModDesign/Codingpublic15.08.2015 09:56
ReporterNagaHuntress Assigned ToSteveL  
PrioritynormalSeveritynormalReproducibilityhave not tried
Status resolvedResolutionfixed 
OSLinux 
Target VersionTDM 2.04Fixed in VersionTDM 2.04 
Summary0004198: A patch to compile libPNG under Linux
DescriptionWhen compiling under recent distros, the latest versions of libPNG some how include "/usr/include/zlib.h" instead of the zlib.h version included with the source. This causes compiler errors due to missing typedefs and defines and breaks the build process. As seen in this post:

http://forums.thedarkmod.com/topic/15289-ubuntu-1310-64-bit-and-32-bit-libs/?p=371909

I've also experienced this under Linux Mint 17.2 (64 bit).

The fix I found to this was just add the libPNG included in the source as part of the SCons build process.
TagsNo tags attached.
Attached Files
tdm-linux-scons-libpng-patch.diff (4,794 bytes)   
Index: SConstruct
===================================================================
--- SConstruct	(revision 6527)
+++ SConstruct	(working copy)
@@ -470,6 +470,7 @@
 g_base_env.Append(CPPPATH = '#/include/zlib')
 g_base_env.Append(CPPPATH = '#/include/minizip')
 g_base_env.Append(CPPPATH = '#/include/libjpeg')
+g_base_env.Append(CPPPATH = '#/include/libpng')
 g_base_env.Append(CPPPATH = '#/include/devil')
 g_base_env.Append(CPPPATH = '#/')
 
Index: sys/scons/SConscript.core
===================================================================
--- sys/scons/SConscript.core	(revision 6527)
+++ sys/scons/SConscript.core	(working copy)
@@ -313,10 +313,11 @@
 	sound_env.Append( CPPDEFINES = 'NO_ALSA' )
 sound_lib = sound_env.StaticLibrary( 'sound', sound_list )
 
-local_env.Append( LIBS = [ 'pthread', 'dl', 'rt', 'png' ] ) # greebo: Added librt and libpng
+local_env.Append( LIBS = [ 'pthread', 'dl', 'rt' ] ) #, 'png' # greebo: Added librt and libpng
 if ( local_dedicated == 0 ):
 	local_env.Append( LIBS = [ 'X11', 'Xext', 'Xxf86vm' ] ) # 'Xxf86dga', 
-	local_env.Append( LIBPATH = [ '/usr/X11R6/lib' ] )
+#	local_env.Append( LIBPATH = [ '/usr/X11R6/lib' ] )
+	local_env.Append( LIBPATH = [ '/usr/lib/i386-linux-gnu' ] )
 #	local_env.Append( LIBS = [ 'openal' ] )
 
 # greebo: Add boost and image libraries
@@ -342,6 +343,8 @@
 # greebo: Use custom compiled devIL and libjpeg (since the engine requires 4 bytes per pixel format) in Linux
 source_list += SConscript( '../../sys/scons/SConscript.devil' )
 source_list += SConscript( '../../sys/scons/SConscript.libjpeg' )
+source_list += SConscript( '../../sys/scons/SConscript.libpng' )
+source_list += SConscript( '../../sys/scons/SConscript.ziploader' )
 
 source_list += g_env_noopt.StaticObject( '../../tools/compilers/dmap/optimize_gcc.cpp' )
 
Index: sys/scons/SConscript.game
===================================================================
--- sys/scons/SConscript.game	(revision 6527)
+++ sys/scons/SConscript.game	(working copy)
@@ -305,7 +305,7 @@
 
 # Link the runtime statically, link statically against libpng.a
 # the corresponding package libpng12-dev must be available on the system
-local_env.Append( LINKFLAGS = [ '-lrt', '-lpng' ] )
+local_env.Append( LINKFLAGS = [ '-lrt' ] ) #, '-lpng'
 
 local_env.Append(LIBS = [
 	# Uncomment this if you're on a x64 system - there is no libpng.a on Ubuntu x64 for instance
@@ -327,8 +327,9 @@
 # greebo: Use custom compiled devIL and libjpeg in Linux
 devil_list = SConscript( '../../sys/scons/SConscript.devil' )
 libjpeg_list = SConscript( '../../sys/scons/SConscript.libjpeg' )
+libpng_list = SConscript( '../../sys/scons/SConscript.libpng' )
 
-full_list = game_list + darkModList + idlib_objects + ziploader_list + devil_list + libjpeg_list
+full_list = game_list + darkModList + idlib_objects + ziploader_list + devil_list + libjpeg_list + libpng_list
 
 ret = local_env.SharedLibrary('game', full_list )
 
Index: sys/scons/SConscript.libpng
===================================================================
--- sys/scons/SConscript.libpng	(revision 0)
+++ sys/scons/SConscript.libpng	(working copy)
@@ -0,0 +1,60 @@
+#*****************************************************************************
+#                    The Dark Mod GPL Source Code
+# 
+# This file is part of the The Dark Mod Source Code, originally based 
+# on the Doom 3 GPL Source Code as published in 2011.
+# 
+# The Dark Mod Source Code is free software: you can redistribute it 
+# and/or modify it under the terms of the GNU General Public License as 
+# published by the Free Software Foundation, either version 3 of the License, 
+# or (at your option) any later version. For details, see LICENSE.TXT.
+# 
+# Project: The Dark Mod (http://www.thedarkmod.com/)
+# 
+# $Revision: 5572 $ (Revision of last commit) 
+# $Date: 2012-09-18 01:35:30 +0930 (Tue, 18 Sep 2012) $ (Date of last commit)
+# $Author: greebo $ (Author of last commit)
+# 
+#*****************************************************************************
+
+import scons_utils
+
+Import( 'GLOBALS' )
+Import( GLOBALS )
+
+libpng_string = ' \
+	png.c \
+	pngerror.c \
+	pngget.c \
+	pngmem.c \
+	pngpread.c \
+	pngread.c \
+	pngrio.c \
+	pngrtran.c \
+	pngrutil.c \
+	pngset.c \
+	pngtrans.c \
+	pngwio.c \
+	pngwrite.c \
+	pngwtran.c \
+	pngwutil.c'
+
+
+libpng_list = scons_utils.BuildList( '', libpng_string )
+
+# greebo: The source files are located in darkmod_src/lib/libpng, for all platforms
+
+for i in range( len( libpng_list ) ):
+	libpng_list[ i ] = '../../lib/libpng/' + libpng_list[ i ]
+
+local_env = g_env.Clone()
+
+# Use the libpng headers
+local_env.Append(CPPPATH = '#/include/libpng')
+
+ret_list = []
+
+for f in libpng_list:
+	ret_list += local_env.SharedObject( source = f )
+
+Return( 'ret_list' )

Activities

tels

tels

14.08.2015 18:44

reporter   ~0007717

The patch makes TDM compile further on my system, so it looks good. Thank you!
SteveL

SteveL

15.08.2015 09:56

reporter   ~0007719

Thanks for the test. Commited at rev 6530

/trunk/SConstruct
/trunk/sys/scons/SConscript.core
/trunk/sys/scons/SConscript.game
/trunk/sys/scons/SConscript.libpng

Issue History

Date Modified Username Field Change
11.08.2015 10:54 NagaHuntress New Issue
11.08.2015 10:54 NagaHuntress File Added: tdm-linux-scons-libpng-patch.diff
14.08.2015 18:44 tels Note Added: 0007717
14.08.2015 19:05 SteveL Assigned To => SteveL
14.08.2015 19:05 SteveL Status new => assigned
15.08.2015 09:56 SteveL Note Added: 0007719
15.08.2015 09:56 SteveL Status assigned => resolved
15.08.2015 09:56 SteveL Resolution open => fixed
15.08.2015 09:56 SteveL Fixed in Version => TDM 2.04
15.08.2015 09:56 SteveL Target Version => TDM 2.04