Jump to content
XCOMUFO & Xenocide

PRG-Compiling On Linux


kurko

Recommended Posts

When compiling on linux im getting an error like:

 

address.cpp: In constructor `Utility::NetworkLib::NLNetworkAddress::NLNetworkAddress(std::basic_string<char,  std::char_traits<char>, std::allocator<char> >)':
../../utility/src/utility/networklib/address.cpp:32: abstract virtual `virtual Utility::StringUtility::NetworkLib::NLNetworkAddress::resolveHostAddress(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)' called from constructor

 

after a bit of googling ive found http://www.geocrawler.com/archives/3/362/1998/5/100/2034292/ , which summing up says:

dont call derived class virtual functions in base class constructor because derived doesnt exist yet.

 

...any idea? :unsure:

 

/edit: wrapped in code tags

Edited by kurko
Link to comment
Share on other sites

and the last ones... gcc doesnt like casting iterators.

 

../../utility/src/utility/networklib/address.cpp: In constructor `Utility::NetworkLib::NLNetworkAddress::NLNetworkAddress(std::basic_string<char,  std::char_traits<char>, std::allocator<char> >)': ../../utility/src/utility/networklib/address.cpp:32: abstract virtual `virtual Utility::StringUtility::NetworkLib::NLNetworkAddress::resolveHostAddress(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)' called from constructor 

make[1]: *** [address.o] Error 1
../../utility/src/utility/paqmanagement/paqfiles/developerstable.cpp: In member function `void Utility::PAQManagement::PAQFiles::PAQDevelopersTable::flushToDisk()': ../../utility/src/utility/paqmanagement/paqfiles/developerstable.cpp:226: no match for `__gnu_cxx::__normal_iterator<Char*, std::vector<Char, std::allocator<char> > >& = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >'  operator /usr/include/c++/3.2/bits/stl_iterator.h:571: candidates are:  __gnu_cxx::__normal_iterator<Char*, std::vector<Char, std::allocator<char> >  >& __gnu_cxx::__normal_iterator<Char*, std::vector<Char, std::allocator<char> > >::operator=(const __gnu_cxx::__normal_iterator<Char*, std::vector<Char, std::allocator<char> > >&)

../../utility/src/utility/paqmanagement/paqfiles/developerstable.cpp:227: no match for `__gnu_cxx::__normal_iterator<Char**, std::vector<Char*,  std::allocator<Char*> > >& = __gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >'   operator 
/usr/include/c++/3.2/bits/stl_iterator.h:571: candidates are: __gnu_cxx::__normal_iterator<Char**, std::vector<Char*, std::allocator<Char*> > >& __gnu_cxx::__normal_iterator<Char**, std::vector<Char*, std::allocator<Char*> > >::operator=(const __gnu_cxx::__normal_iterator<Char**, std::vector<Char*, 
  std::allocator<Char*> > >&)
../../utility/src/utility/paqmanagement/paqfiles/developerstable.cpp:229: no matching function for call to `std::vector<Char, std::allocator<char> >::insert(__gnu_cxx::__normal_iterator<Char*, std::vector<Char, std::allocator<char> > >&, __gnu_cxx::__normal_iterator<Char*, std::vector<Char, std::allocator<char> > >&,  __gnu_cxx::__normal_iterator<Char**, std::vector<Char*, std::allocator<Char*> > >&)'
/usr/include/c++/3.2/bits/stl_vector.h:540: candidates are: __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> > std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*, 
  std::vector<_Tp, _Alloc> >, const _Tp&) [with _Tp = Char, _Alloc = std::allocator<char>]
/usr/include/c++/3.2/bits/stl_vector.h:564:     __gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> > std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*,  std::vector<_Tp, _Alloc> >) [with _Tp = Char, _Alloc = std::allocator<char>]
/usr/include/c++/3.2/bits/stl_vector.h:613:                 void std::vector<_Tp, _Alloc>::insert(__gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >, unsigned int, const _Tp&) [with _Tp = Char, 
  _Alloc = std::allocator<char>]
../../utility/src/utility/paqmanagement/paqfiles/developerstable.cpp:248: cannot convert `std::vector<_Tp, _Alloc>::begin() [with _Tp = Char, _Alloc =  std::allocator<char>]()' from type `__gnu_cxx::__normal_iterator<Char*,  std::vector<Char, std::allocator<char> > >' to type `UInt8*'

 

 

...without those, qa, mathlib, networklib, misc, paqsystem compile fine.

what are we going to do about xenoengine??, replace it with SDL perhaps??

Link to comment
Share on other sites

Hi kurko, thanks on signaling this bugs !!

 

I developed the paqsystem subproject and I checked the errors in paqdeveloperstable.cpp

 

In the signaled lines there is not something that can give errors...

I've found some code that can give problems on the third lines above instead

 

line 224: I think I've got it

line 226: got it

line 245: got it

 

I have to rewrite some code in order to make it work I'll PM you when I've done it and updated the cvs files

Link to comment
Share on other sites

Will you have free time for that? I thought though we don't mind people trying to make a port on their own but that we were just doing a windows version?
Link to comment
Share on other sites

However that is a real problem that I didnt notice (in every platform). In other languages you can call virtual methods in the base constructor in C++ you dont... That can introduce nasty defects (and not easily trackeable ones)...

 

Greetings

Red Knight

Link to comment
Share on other sites

Oh I see a little work now to allow *any* port in the future. Yes, IIRC we agreed about doing things that way. Nevermind then.

 

Of course the QAD thing is to throw in a conditional compile statement to cover the windows stuff and let /them/ worry about their own house. :wink:

Link to comment
Share on other sites

none of those are platform dependant bugs, they appear on linux because gcc is more strict (didnt say better), with a conditional compile you are only hiding them.

 

.... and yeap, i want those bugs out of my house or i will call the X-Corps!! :D

Link to comment
Share on other sites

NOO please don't call X-Corps !! :whatwhat:

I've just updated the sources in the CVS, tell me if the paqdeveloperstable.cpp errors are corrected !!

Link to comment
Share on other sites

sorry to be such a pain but nope.... ive attached a diff with the needed changes to make it compile (caution notice: dont use at home, some things should stop working).

 

if anyone is interested I have managed to compile everything (but the examples), including xenoengine without the kernel/win32 (if you link against it you'll get unresolved refs).

diff.out

Link to comment
Share on other sites

Note that I updated also the iolib package, you need to redownload it in order to correct the "this->fileName" errors

 

Tell us more about what you changed in the other sources to make it compile

Link to comment
Share on other sites

thought i had checked out the iolibs too.... :hammer:

 

ive changed many little things, like calls to function that dont exist on linux, like in networklib in_addr doesnt have an S_un.S_addr, its s_addr. Made include the GL/gl.h of the current os cause the one in thirdparty is win32 specific, and silly stuff like that.

 

The devpack generator is almost ready for a 0.000001 release, it generates the projects with the solution. As soon as it compiles on gcc & vc7 i will release it. As of now Im changing more silly stuff to make it compile without warnings in vc7. :D

 

 

I guess ive found another bug in utility/src/utility/networklib/factories/inprocconnection.cpp line 179

 

UInt8* ownData = new UInt8 (size);

 

shouldnt it be?

 

UInt8* ownData = new UInt8 ;

 

otherwise its the same as

 

UInt8* ownData = new UInt8 [1];

ownData[0] = size;

memcpy (ownData, data, size); // <-- Bye bye!!

Link to comment
Share on other sites

That is fun, actually I really dont know the different semantics of those. For me it used to be the same, can you explain further...

 

In fact when initializing memory I tend to use malloc instead of that constructors cause most of the time they create very digusting problems...

 

Greetings

Red Knight

Link to comment
Share on other sites

I think if you use the () brackets you pass the inner value as a parameter of the constructor, so the compiler understands that you create a single UInt8 with value "size".

You have to use the [] to specify creating an array.

 

A difference between the "new" operator and the "malloc" function is that "malloc" doesn't call the constructor of the class/es created

Link to comment
Share on other sites

I think if you use the () brackets you pass the inner value as a parameter of the constructor, so the compiler understands that you create a single UInt8 with value "size".

You have to use the [] to specify creating an array.

 

A difference between the "new" operator and the "malloc" function is that "malloc" doesn't call the constructor of the class/es created

You shall be called a 'professor'!

The answer is right. () is call to a method (in this case constructor). [] specify the creation of array.

Link to comment
Share on other sites

Ok, got the difference now... Shame on me to dont know it.

 

Kurko: Can you send me a diff of the network library changes and the engine ones I will be at home 2 days with full internet connection so I may find an hour or so to check the changes and commit them to the CVS...

 

Greetings

Red Knight

Link to comment
Share on other sites

×
×
  • Create New...