Game Development Community

GCC 3.4.2 and all that; overhaul the build system!

by Philip Allison · in Torque Game Engine · 12/28/2004 (2:29 am) · 6 replies

OpenTNL has severe problems compiling with GCC 3.4.2 (and, presumably, above). Use of the "-fpermissive" flag is necessary to get the compiler to accept tnlVector.h:
In file included from tnlUDP.h:35,
                 from tnl.h:51,
                 from assert.cpp:27:
tnlVector.h: In member function 'T& TNL::Vector<T>::front()':
tnlVector.h:301: error: there are no arguments to 'begin' that depend on a template parameter, so a declaration of 'begin' must be available
tnlVector.h:301: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
tnlVector.h: In member function 'const T& TNL::Vector<T>::front() const':
tnlVector.h:306: error: there are no arguments to 'begin' that depend on a template parameter, so a declaration of 'begin' must be available
tnlVector.h: In member function 'T& TNL::Vector<T>::back()':
tnlVector.h:311: error: there are no arguments to 'end' that depend on a template parameter, so a declaration of 'end' must be available
tnlVector.h: In member function 'const T& TNL::Vector<T>::back() const':
tnlVector.h:316: error: there are no arguments to 'end' that depend on a template parameter, so a declaration of 'end' must be available
make[1]: *** [assert.o] Error 1
make: *** [default] Error 2
Adding -fpermissive to the CFLAGS in necessary Makefiles gets past this.

We then have a virtual member function being initialised to NULL, where GCC wants zero:
In file included from tnlNetObject.h:39,
                 from tnlNetInterface.h:41,
                 from eventConnection.cpp:31:
tnlRPC.h: At global scope:
tnlRPC.h:167: error: expected '0' before ""
tnlRPC.h:167: error: invalid initializer for virtual method 'virtual bool TNL::RPCEvent::checkClassType(TNL::Object*)'
tnlRPC.h:167: error: expected ';' before ""

Changing the NULL on line 167 to 0 fixes this, and AFAIK is no different functionally. (I'm primarily self-taught, and have never thought initialising virtual functions to anything other than zero was correct; I wonder where this was picked up...)

Then there's the issue of the seemingly unnecessary Platform::checkHeap() function in platform.cpp. This is only defined on Windows, and compilation doesn't seem to suffer if it is simply removed entirely!

Having compiled tnl, there are then countless errors in libtomcrypt, ALL seemingly due to using the wrong syntax for including headers. Putting "-I./" in CFLAGS is unnecessary, and all local header files - i.e. those in the libtomcrypt source directory - should use
#include "header.h"
rather than
#include <header.h>
The latter is more correct and, quite simply, works.

I'm trying to compile using the latest MinGW, and had to make the above changes before I got anywhere. I've now run up against linker errors, which at first glance look like they're due to not linking against winsock libraries. I *would* go further and try to submit these changes to CVS, but the "Joint Copyright Assignment" you have to fill in before contributing has gone AWOL! Try the links on this page to see what I mean: opentnl.org/contribute.php

If this library aims at true cross-platform compatibility, these updates need to be made, and I'd also suggest switching to an Automake/conf build system for UNIXish platforms. This would make adding official support for MinGW on Windows fairly trivial, and does not preclude having additional make or project files for compilers such as Visual C/C++. I've just started writing a framework for a new game, two goals of which are to run on at least Windows and Linux and to use open-source development tools and libraries; OpenTNL sounds perfect for the network layer in principle, but in reality, it needs some maintenance work. Which I'd happily offer to do, if I had more spare time, and could sign the necessary agreement for contribution!

About the author

Recent Threads


#1
12/29/2004 (4:37 pm)
Hey Philip, we're going to do a new release of TNL shortly, and we'll make sure to address the compiler issues. We'll also get that form back online (hmm.. where'd it go?), so that you can join the team. I definitely like the autoconf idea - though right now TNL will only work on x86 or PPC platforms due to assembly code issues.
#2
02/24/2005 (2:49 pm)
Opentnl 1.5.0 still fails to build with gcc 3.4 (3.4.3 here) without -fpermissive and then fails with:

make[2]: Entering directory '/usr/src/tnl/libtomcrypt'
cc -O -march=athlon-xp -mmmx -mfpmath=sse -msse -m3dnow -pipe -DPIC -fPIC -Os -fpermissive -c -o keyring.o keyring.c
cc1: warning: command line option "-fpermissive" is valid for C++/ObjC++ but not for C
keyring.c:2:21: mycrypt.h: No such file or directory
make[2]: *** [keyring.o] Error 1
make[2]: Leaving directory '/usr/src/tnl/libtomcrypt'
make[1]: *** [default] Error 2
make[1]: Leaving directory '/usr/src/tnl'

I used 'make CFLAGS="-fpermissive"' to compile.

Here's a patch to fix the -fpermissive (well, it adds -fpermissive where needed, not actually "fixing" the problem):

diff -Naur tnl.orig/tnl/Makefile tnl/tnl/Makefile
--- tnl.orig/tnl/Makefile 2005-02-24 15:25:53.515241112 -0800
+++ tnl/tnl/Makefile 2005-02-24 15:28:04.503327896 -0800
@@ -7,7 +7,7 @@
#
# Configuration
#
-CC=g++ -g -DTNL_DEBUG -DTNL_ENABLE_LOGGING -I../libtomcrypt # -O2
+CC=g++ -g -DTNL_DEBUG -DTNL_ENABLE_LOGGING -I../libtomcrypt -fpermissive # -O2

OBJECTS=\
assert.o\



And here's a patch for the includes:
diff -Naur tnl.orig/libtomcrypt/mycrypt.h tnl/libtomcrypt/mycrypt.h
--- tnl.orig/libtomcrypt/mycrypt.h 2005-02-24 15:25:53.555235032 -0800
+++ tnl/libtomcrypt/mycrypt.h 2005-02-24 15:30:55.581320088 -0800
@@ -9,7 +9,7 @@
#include

/* if there is a custom definition header file use it */
-#include
+#include "mycrypt_custom.h"

#ifdef __cplusplus
extern "C" {
@@ -61,16 +61,16 @@
};
/* ch1-01-1 */

-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include "mycrypt_cfg.h"
+#include "mycrypt_macros.h"
+#include "mycrypt_cipher.h"
+#include "mycrypt_hash.h"
+#include "mycrypt_prng.h"
+#include "mycrypt_pk.h"
+#include "mycrypt_gf.h"
+#include "mycrypt_misc.h"
+#include "mycrypt_kr.h"
+#include "mycrypt_argchk.h"

#ifdef __cplusplus
}



But then I still receive this error:
make[1]: Entering directory '/usr/src/tnl/libtomcrypt'
cc -c -I./ -Wall -Wsign-compare -W -Wno-unused -Wshadow -Werror -Os -c -o tiger.o tiger.c
tiger.c:544: warning: conflicting types for built-in function 'round'
make[1]: *** [tiger.o] Error 1
make[1]: Leaving directory '/usr/src/tnl/libtomcrypt'
make: *** [default] Error 2

I'm not sure why it's failing on a warning...
#3
02/25/2005 (8:51 am)
Hmm... dunno what that funky error is, but I've checked in fixes for the other errors. The -fpermissive one was actually some missing functions in the Vector template. Looks like GCC 3.4.2 has better template checking than prior versions.
#4
04/13/2005 (1:46 pm)
(OpenTNL 1.5)

If you replace tnl/libtomcrypt/tiger.c with src/hashes/tiger.c from the official libtomcrypt 1.00 source, then the warning error goes away and the build continues.

Also, adding '-fpermissive' to the CFLAGS in all the recursively called Makefiles will finally get OpenTNL to build with GCC 3.4 (3.4.3 in my case).

'-fpermissive' is further required for any code that is linked against the OpenTNL headers, otherwise it will produce the template errors that Philip Allison first had above just building OpenTNL.
#5
02/12/2006 (8:30 pm)
Running into the same errors as Phillip with 1.5 downloaded from SourceForge. I'm noticing these messages are very old, is there are significantly more compilable version in CVS?
#6
06/13/2006 (4:19 pm)
I've just checked out the CVS and all I can say is that the Linux build does not work as-is and the ReadMe.html is virtually useless. Once I get it compiling I'll post a patch somewhere.