CVS Compiling Problems - And My Solutions

Need help testing contributed art or code or having trouble getting your newest additions into game compatible format? Confused by changes to data formats? Reading through source and wondering what the developers were thinking when they wrote something? Need "how-to" style guidance for messing with VS internals? This is probably the right forum.
Post Reply
rogue
Explorer
Explorer
Posts: 14
Joined: Sun Aug 07, 2005 4:52 pm
Contact:

CVS Compiling Problems - And My Solutions

Post by rogue »

There are a few straightforward (and some not so straightforward)problems I found when building, most are pretty easily solved (using gcc4.1, fedora core 2) (Note: This is the second time I've tried compiling vegastrike so I'm not very familiar with it yet.. but I did get the cvs source running at least(Tho I couldn't BUY half of anything that was white, if I clicked buy it just sat there, and dumped an error to the screen about tried to quit, if this wasn't what you wanted tell somebody)

Note: I'm writing this as I'm compiling the latest vegastrike from about 3 hours ago.
----
One problem was a complaint about a class missing (Although the gcc error looked nothing like it, after changing a lot of stuff I finally got an error about a missing class)(NavComputer) in the class navScreen, the reason for this is the redundency the #ifdef #define huge code snippet #endif allows with the #including..


The way to fix this, was to, in the c++ file generating the problem(vegastrike/src/gfx/navcomputer.cpp)
change #include "navcomputer.h" to #include "navscreen.h"
Since navscreen.h already includes navcomputer, and navcomputer includes navscreen, but ok this redundency.....

The exact error gcc gave is:
if g++ -DHAVE_CONFIG_H -I. -I. -I../../.. -DHAVE_SDL=1 -DSDL_WINDOWING=1 -DHAVE_SDL=1 -DSDL_WINDOWING=1 -DHAVE_AL=1 -DHAVE_OGG -I/usr/include/python2.3 -DHAVE_PYTHON=1 -DUSE_BOOST_131=1 -I../../../src/boost129 -I../../../src -pipe -falign-loops=2 -falign-jumps=2 -falign-functions=2 -I/usr/local/include/SDL -D_REENTRANT -pthread -pipe -MT navcomputer.o -MD -MP -MF ".deps/navcomputer.Tpo" -c -o navcomputer.o navcomputer.cpp; \
then mv -f ".deps/navcomputer.Tpo" ".deps/navcomputer.Po"; else rm -f ".deps/navcomputer.Tpo"; exit 1; fi
navscreen.h:142: error: ISO C++ forbids declaration of ‘NavComputer’ with no type
navscreen.h:142: error: expected ‘;’ before ‘*’ token




--------------------------------------------------------------------------
Another problem I encountered was a missing copy constructor. (This one seems to have been fixed in the past two or three days)
There was a struct class with resizable data in it, that was being returned from a function
func(args) {
ClassName y; //local version always uses copy constructor
do stuff, setup y
return y; //here
}
(and returning a class is the same as doing:
className x(const &y);
or className *x = new x(const &y)

in the case of gcc:
alloc(sizeof(class));

memcpy(y, this, sizeof(y)); //can generate memleaks if you use resizable data, like std::strings, or whatnot (This method is fine for floats, ints, and built in types, fixed arrays, but not strings, vectors, or anything resizeable)

So I fixed it by adding a copy constructor to replace the one generated
className (const className &in) {
if(in.str.size() > 0) str.append(in.str);
if(in.desc.size() >0) desc.append(in.desc);
player = in.player;
}
(Sorry, I don't remember what file this was in, GCC caught it and reported a very ugly error about bad allocation or something), and it doesn't report this error on the last compile.

-- Copy constructors and vectors:
In the case of Vectors which iterators are the best way of accessing, which require read-write mode , a very simple solution is const_cast:
className *pointer = const_cast<className *>(&in);



-- Destructor problem:

Yet another problem
(This one was just a warning , but there are tons of them, and in this particular case it looks like it doesn't need a destructor, unless any of those 6 pointers are initialized with a new, in which case a bool for each of the pointers might be useful (every time you use a new, set the bool to true, that gives protection against double allocations(with an if somewhere before the alloc call (new)), and you have a way of knowing wether it's allocated or not when the destructor is called so you can run a delete)).

was a base class (one that's inherited by others) that has virtual functions but no virtual destructor (Just a warning)
vegastrike/src/physics.h:39: warning: ‘class PhysicsSystem’ has virtual functions but non-virtual destructor
(uncommentining the commented destructor, adding virtual, and giving it {} fix's it)
virtual ~PhysicsSystem() {}; //it still removes all the local non pointers allocated by the compiler, anything allocated with a new should be destroyed here, but only things on this object.


--Accessing a private value:
vsimage.cpp
../../src/vsfilesystem.h:262: error: ‘char* VSFileSystem::VSFile::pk3_extracted_file’ is private
(My fix was to simply make it public, but a better way there may be)


--Undefined references:
cmd/ai/libai.a(firekeyboard.o)(.text+0x771): In function `__tcf_23':
: undefined reference to `FireKeyboard::ProcessCommMessage(CommunicationMessage&)::comm_static'
cmd/ai/libai.a(firekeyboard.o)(.text+0x785): In function `__tcf_24':
: undefined reference to `FireKeyboard::ProcessCommMessage(CommunicationMessage&)::Statuc'

These were weird.. I tried a few things to get rid of them, all at once, I'm thinking it could have just been something went wrong with g++ the first time around...
Anyhow, I changed the makefile in the cmd/ai , added -g -O3 -Wall
opened up firekeyboard.cpp , removed the whitespace, and added the one:
void ProcessCommMessage (class CommunicationMessage&in) <-old one
void ProcessCommMessage(class CommunicationMessage &in);//new one.
,
did a make clean, remade, and it worked.
rogue
Explorer
Explorer
Posts: 14
Joined: Sun Aug 07, 2005 4:52 pm
Contact:

Post by rogue »

void ProcessCommMessage (class CommunicationMessage&in) <-old one

The error here wasn't in the missing space, it was a g++ bug with static variables and objects, and not knowing something about it(hellcat explained it best)

It was in the two static variables, and the third function call after them.
static std::string comm_something
static Animation Statuc
some_Function_Call_that_uses_comm_and_statuc

The way to fix it was to move them to a function just abouve FireKeyboard::ProcessCommMessage
like:
static void myFunction() {
static std::string comm
static Animation Statuc
function_call();
}

Then call myFunction() where the other three used to be
Wisq
ISO Party Member
ISO Party Member
Posts: 453
Joined: Sat Jul 30, 2005 10:21 am

Post by Wisq »

I've heard and seen a lot of programs break under GCC 4. Things that were warnings (or not even mentioned) in previous GCC versions have now become fatal errors. It's good for code quality, but bad for people who have GCC 4 installed by default and probably shouldn't yet.

Personally, I used GCC 3.4 to compile VS, and had no problems with the CVS tree. If you're looking for an immediate solution, that's it. GCC 4 problems will need to be addressed eventually, though, so thanks for pointing them out.
zbyszanna
Hunter
Hunter
Posts: 83
Joined: Tue Sep 13, 2005 3:49 pm
Location: Poland

Post by zbyszanna »

Hi
I hust downloaded source from repository and it seems to be all messed up. For example:
file src/cmd/weapons.h includes "gfx/vec.h" and there is no directory named gfx in src/cmd, there is one in src.

Did I do something wrong? I checked out the vegastrike module from anonymous access.
hellcatv
Developer
Developer
Posts: 3980
Joined: Fri Jan 03, 2003 4:53 am
Location: Stanford, CA
Contact:

Post by hellcatv »

it includes src/ as a toplevel dir

all includes are from src/ or the current dir...
:-)
or even vegastrike/
Vega Strike Lead Developer
http://vegastrike.sourceforge.net/
zbyszanna
Hunter
Hunter
Posts: 83
Joined: Tue Sep 13, 2005 3:49 pm
Location: Poland

Post by zbyszanna »

Ok, many problems gone, but there is one with boost. I downloaded 1.33 from boost.org, installed it and now I run into problems with it. I see that there are boost directories in vegastrike (boost129, boost, boost129/boost, boost/boost) - how to include them? I tried to set the include path to src/boost129 (the same as with 133, "Python not declared as a class" when used with Python::reseterrors()) and to src/boost (some problems with boost itself, missing files etc).

'Building file: ../src/command.cpp'
'Invoking: GCC C++ Compiler'
D:\programming\mingw-3.4.4\bin\g++.exe -I"D:\programming\mingw-3.4.4\include" -ID:/programming/workspace/vegastrike/src -ID:/programming/workspace/vegastrike -O0 -g3 -c -fmessage-length=0 -osrc/command.o ../src/command.cpp
In file included from ../src/command.cpp:8:
../src/python/python_class.h: In static member function `static PythonClass<SuperClass>* PythonClass<SuperClass>::FactoryString(char*)':
../src/python/python_class.h:187: error: `Python' has not been declared
../src/python/python_class.h:187: error: there are no arguments to `reseterrors' that depend on a template parameter, so a declaration of `reseterrors' must be available
../src/python/python_class.h:187: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
../src/python/python_class.h:189: error: `Python' has not been declared
../src/python/python_class.h:189: error: there are no arguments to `reseterrors' that depend on a template parameter, so a declaration of `reseterrors' must be available
../src/python/python_class.h: In member function `virtual void pythonMission::Execute()':
../src/python/python_class.h:251: error: `Python' has not been declared
../src/python/python_class.h:251: error: `reseterrors' undeclared (first use this function)
../src/python/python_class.h:251: error: (Each undeclared identifier is reported only once for each function it appears in.)
../src/python/python_class.h: In member function `virtual std::string pythonMission::Pickle()':
../src/python/python_class.h:254: error: `Python' has not been declared
../src/python/python_class.h:254: error: `reseterrors' undeclared (first use this function)
../src/python/python_class.h:260: error: `Python' has not been declared
../src/python/python_class.h: In member function `virtual void pythonMission::UnPickle(std::string)':
../src/python/python_class.h:264: error: `Python' has not been declared
../src/python/python_class.h:264: error: `reseterrors' undeclared (first use this function)
../src/python/python_class.h:270: error: `Python' has not been declared
../src/command.cpp: In member function `void RegisterPythonWithCommandInterp::runPy(std::string&)':
../src/command.cpp:1263: error: `Python' has not been declared
../src/command.cpp:1263: error: `reseterrors' undeclared (first use this function)
../src/python/python_class.h: In static member function `static PythonClass<SuperClass>* PythonClass<SuperClass>::FactoryString(char*) [with SuperClass = PythonMissionBaseClass]':
../src/python/python_class.h:285: instantiated from here
../src/python/python_class.h:187: error: `reseterrors' undeclared (first use this function)
make: *** [src/command.o] Error 1

Another problem is with ogl, when I copied ogl form vega-proj-new (or smth), I get these messages:

'Building file: ../src/gfxlib_struct.cpp'
'Invoking: GCC C++ Compiler'
D:\programming\mingw-3.4.4\bin\g++.exe -I"D:\programming\mingw-3.4.4\include" -ID:/programming/workspace/vegastrike/src -ID:/programming/workspace/vegastrike -O0 -g3 -c -fmessage-length=0 -osrc/gfxlib_struct.o ../src/gfxlib_struct.cpp
In file included from ../src/gfxlib_struct.cpp:3:
../src/gldrv/gl_globals.h:132: error: `PFNGLBINDBUFFERARBPROC' does not name a type
../src/gldrv/gl_globals.h:133: error: `PFNGLGENBUFFERSARBPROC' does not name a type
../src/gldrv/gl_globals.h:134: error: `PFNGLDELETEBUFFERSARBPROC' does not name a type
../src/gldrv/gl_globals.h:135: error: `PFNGLBUFFERDATAARBPROC' does not name a type
../src/gldrv/gl_globals.h:136: error: `PFNGLMAPBUFFERARBPROC' does not name a type
../src/gldrv/gl_globals.h:137: error: `PFNGLUNMAPBUFFERARBPROC' does not name a type

maybe it is incorrect ogl version? But what about boost?
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Post by klauss »

I think you really have to know what you're doing if you want to switch boost versions. Best try would be replacing what's inside boost129 with the boost 1.33 files, and leave everything else as is. But still... no guarantee.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
zbyszanna
Hunter
Hunter
Posts: 83
Joined: Tue Sep 13, 2005 3:49 pm
Location: Poland

Post by zbyszanna »

klauss wrote:I think you really have to know what you're doing if you want to switch boost versions. Best try would be replacing what's inside boost129 with the boost 1.33 files, and leave everything else as is. But still... no guarantee.
I don't want to switch boost versions. I just want vegastrike to compile, as I am unable to do it at the moment.
Now, I have following folders set as source folders (so they are the top of include hierarchy):
vegastrike/
vegastrike/src/
mycompiler/include/

If I leave it as it is, there is no file that matches "boost/python.hpp".
If I add vegastrike/src/boost129 to include path - I got these "Python undeclared" errors.
If I add vegastrike/src/boost to include path - I got other missing files in boost.
If I add both vegastrike/src/boost and vegastrike/src/boost129 to include path - the situation is similiar to including only boost129
Post Reply