compiler questions

Questions, problems and discussion about compiling FreeOrion.

Moderators: Oberlus, Oberlus

Message
Author
User avatar
loonycyborg
Compilation Expert
Posts: 219
Joined: Thu Jul 06, 2006 10:30 pm
Location: Russia/Moscow

#46 Post by loonycyborg » Sat Sep 16, 2006 11:15 pm

I have exactly the same problem. If compiled with gcc-4.1.1, FreeOrion runs extremely unstable. For example, it always crashes if I click "Colonize" button.
However, it runs stable if compiled with gcc-3.4.5.
I have Gentoo Linux too, so maybe it's Gentoo-specific bug?

User avatar
tzlaine
Programming Lead Emeritus
Posts: 1092
Joined: Thu Jun 26, 2003 1:33 pm

#47 Post by tzlaine » Sun Sep 17, 2006 6:04 am

The most likely source of the problems in your case is ABI incompatability. If you are running a system with libraries built with gcc 3.4.5, and then you build FO and GG with gcc 4.1.1 (or vice versa), you're probably linking against two versions of libstdc++, and maybe others. Even if you're only linking against one of them, odds are you are linking C++ code built with one compiler against code built with another, which will almost always blow up in your face. Note that C does not suffer from ABI compatability issues, only C++.

User avatar
loonycyborg
Compilation Expert
Posts: 219
Joined: Thu Jul 06, 2006 10:30 pm
Location: Russia/Moscow

#48 Post by loonycyborg » Mon Sep 18, 2006 11:06 pm

I really doubt that since after I started getting these errors, I reemerged(recompiled) all FreeOrion's and GG's dependencies, cleaned (scons -c) FreeOrion and GG and recompiled them. After that I still had these errors.
Then I switched compiler profile to gcc-3.4.5 and tried to recompile FO and GG. GG compiled OK but FO got linker error about log4cpp. After I reemerged log4cpp, FreeOrion compiled too and when I ran it, there where no crashes.
So if FreeOrion and it' s dependencies are all compiled with gcc-4.1.1, it crashes. But if FreeOrion, GG and log4cpp are compiled with gcc-3.4.5 but all other dependencies are compiled with gcc-4.1.1, it runs fine. :?

User avatar
tzlaine
Programming Lead Emeritus
Posts: 1092
Joined: Thu Jun 26, 2003 1:33 pm

#49 Post by tzlaine » Tue Sep 19, 2006 3:28 pm

libstdc++ is one of FO's dependencies. Did you recompile it as well?

Try this: run "ldd freeorion", and post the results here.

User avatar
loonycyborg
Compilation Expert
Posts: 219
Joined: Thu Jul 06, 2006 10:30 pm
Location: Russia/Moscow

#50 Post by loonycyborg » Thu Sep 21, 2006 10:07 pm

libstdc++ is recompiled when gcc is, by the "emerge" script. When compiler profile changes, symlinks in /usr/lib are updated to point to corresponding gcc's libstdc++.

Here's output of "ldd freeorion"


$ ldd freeorion
linux-gate.so.1 => (0xffffe000)
libGiGiSDL.so => /usr/local/lib/libGiGiSDL.so (0xb7ee7000)
libSDL-1.2.so.0 => /usr/lib/libSDL-1.2.so.0 (0xb7e8d000)
libGiGiNet.so => /usr/local/lib/libGiGiNet.so (0xb7e84000)
libIL.so.1 => /usr/lib/libIL.so.1 (0xb7d71000)
libILU.so.1 => /usr/lib/libILU.so.1 (0xb7d58000)
libILUT.so.1 => /usr/lib/libILUT.so.1 (0xb7d53000)
libGiGi.so => /usr/local/lib/libGiGi.so (0xb7b9d000)
libboost_signals.so.1.33.1 => /usr/lib/libboost_signals.so.1.33.1 (0xb7b8c000)
libboost_filesystem.so.1.33.1 => /usr/lib/libboost_filesystem.so.1.33.1 (0xb7b7b000)
libGL.so.1 => /usr/lib/opengl/nvidia/lib/libGL.so.1 (0xb7af6000)
libGLU.so.1 => /usr/lib/libGLU.so.1 (0xb7a7e000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7a6b000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xb79ec000)
libz.so.1 => /lib/libz.so.1 (0xb79d8000)
libboost_serialization.so.1.33.1 => /usr/lib/libboost_serialization.so.1.33.1 (0xb7974000)
libboost_iostreams.so.1.33.1 => /usr/lib/libboost_iostreams.so.1.33.1 (0xb796b000)
libgraph.so.2 => /usr/lib/graphviz/libgraph.so.2 (0xb7960000)
libcdt.so.2 => /usr/lib/graphviz/libcdt.so.2 (0xb795a000)
libgvc.so.2 => /usr/lib/graphviz/libgvc.so.2 (0xb78df000)
liblog4cpp.so.3 => /usr/lib/liblog4cpp.so.3 (0xb78b0000)
libstdc++.so.6 => /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libstdc++.so.6 (0xb77d7000)
libm.so.6 => /lib/libm.so.6 (0xb77b3000)
libgcc_s.so.1 => /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/libgcc_s.so.1 (0xb77a8000)
libc.so.6 => /lib/libc.so.6 (0xb7692000)
libdl.so.2 => /lib/libdl.so.2 (0xb768e000)
libX11.so.6 => /usr/lib/libX11.so.6 (0xb7594000)
libXext.so.6 => /usr/lib/libXext.so.6 (0xb7583000)
libpng.so.3 => /usr/lib/libpng.so.3 (0xb755e000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb7540000)
libtiff.so.3 => /usr/lib/libtiff.so.3 (0xb74ee000)
libGLcore.so.1 => /usr/lib/opengl/nvidia/lib/libGLcore.so.1 (0xb6d2d000)
libnvidia-tls.so.1 => /usr/lib/opengl/nvidia/lib/libnvidia-tls.so.1 (0xb6d2b000)
/lib/ld-linux.so.2 (0xb7f08000)
libbz2.so.1 => /lib/libbz2.so.1 (0xb6d19000)
libpathplan.so.2 => /usr/lib/graphviz/libpathplan.so.2 (0xb6d11000)
libgvgd.so.2 => /usr/lib/graphviz/libgvgd.so.2 (0xb6cc1000)
libexpat.so.0 => /usr/lib/libexpat.so.0 (0xb6ca1000)
libltdl.so.3 => /usr/lib/libltdl.so.3 (0xb6c9a000)
libnsl.so.1 => /lib/libnsl.so.1 (0xb6c85000)
libXau.so.6 => /usr/lib/libXau.so.6 (0xb6c82000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb6c7d000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0xb6c56000)


Also, I'm getting this strange compiler warning

ccache g++ -pthread -Wall -O2 -DFREEORION_LINUX -DENABLE_BINRELOC -DFREEORION_BUILD_HUMAN -I/usr/include/SDL -I/usr/local/include -I/usr/include/graphviz -I/usr/include/graphviz -c -o universe/Universe-human.o universe/Universe.cpp
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/ext/new_allocator.h: In member function 'void Universe::InitializeSystemGraph()':
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/ext/new_allocator.h:106: warning: 'p$m_value' is used uninitialized in this function

when compiling with gcc-4.1.1 but not with 3.4.5

User avatar
tzlaine
Programming Lead Emeritus
Posts: 1092
Joined: Thu Jun 26, 2003 1:33 pm

#51 Post by tzlaine » Fri Sep 22, 2006 2:19 am

I'm at a loss. I don't know what that error means, and there's no "m_value" in that file (and of course "p$m_value" is illegal syntax). I know that FO compiles and runs fine on a system with one compiler, and I use gcc 4.1 during development. I have no idea what's causing your problems, sorry.

User avatar
noelte
Juggernaut
Posts: 872
Joined: Fri Dec 26, 2003 12:42 pm
Location: Germany, Berlin

#52 Post by noelte » Fri Sep 22, 2006 9:04 am

I don't even see an error. It's a warning.
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/ext/new_allocator.h:106: warning: 'p$m_value' is used uninitialized
And i don't think, m_value has to be in new_allocator.h. I don't have the source at the moment, but Universe.xxx might contain an attribute m_value (or related class). I would guess p$ is just generated when using m_value in a template.....
Press any key to continue or any other key to cancel.
Can COWs fly?

User avatar
MareviQ
Space Kraken
Posts: 100
Joined: Tue Aug 09, 2005 6:47 pm
Location: Somewhere in Poland

#53 Post by MareviQ » Sun Sep 24, 2006 9:16 pm

I currently have version 1892 of FreeOrion svn and version 540 of GG that comes with it and I can't get it to compile with gcc-4.1.1.
GG compiles cleanly (after adding SConsignFile() line at the beginning of the SConstruct file) but FreeOrion dies with the following error:

Code: Select all

Empire/../Empire/ResourcePool.h:24: error: extra qualification 'ResourcePool::' on member 'ResourcePool'
Empire/../Empire/ResourcePool.h:77: error: extra qualification 'PopulationPool::' on member 'PopulationPool'
yes, I know that the problem is trivial but it still exists. After correcting that the compiler dies horribly while compiling ResourcePool.cpp and to bo exact, while going over this function:

Code: Select all

void PopulationPool::SetPopCenters(const std::vector<PopCenter*>& pop_center_vec)
{
    m_pop_centers = pop_center_vec;
    std::sort(m_pop_centers.begin(), m_pop_centers.end(), &PopCenterLess);  // this ordering ensures higher population PopCenters get first priority for food distribution
}
the error generated is

Code: Select all

/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h: In function ‘const _Tp& std::__median(const _Tp&, const _Tp&, const _Tp&, _Compare) [with _Tp = PopCenter*, _Compare = bool (*)(PopCenter*&, PopCenter*&)]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:2679:   instantiated from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<PopCenter**, std::vector<PopCenter*, std::allocator<PopCenter*> > >, _Size = int, _Compare = bool (*)(PopCenter*&, PopCenter*&)]’
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:2749:   instantiated from ‘void std::sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<PopCenter**, std::vector<PopCenter*, std::allocator<PopCenter*> > >, _Compare = bool (*)(PopCenter*&, PopCenter*&)]’
Empire/ResourcePool.cpp:161:   instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:125: error: invalid initialization of reference of type ‘PopCenter*&’ from expression of type ‘PopCenter* const’
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:126: error: invalid initialization of reference of type ‘PopCenter*&’ from expression of type ‘PopCenter* const’
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:128: error: invalid initialization of reference of type ‘PopCenter*&’ from expression of type ‘PopCenter* const’
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:132: error: invalid initialization of reference of type ‘PopCenter*&’ from expression of type ‘PopCenter* const’
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:134: error: invalid initialization of reference of type ‘PopCenter*&’ from expression of type ‘PopCenter* const’
/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4/bits/stl_algo.h:137: warning: control reaches end of non-void function
which is frankly a lot of gibberish to me, and quite suprising, too as it dies somewhere in STL library, which up until now I considered quite safe

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12519
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

#54 Post by Geoff the Medio » Sun Sep 24, 2006 9:56 pm

The extra ClassName:: on the constructors is my fault, and should be now fixed in SVN.

The other error is seemingly related to using std::sort() on the PopCenter vector... I'm not sure what the problem is though, as it seems to be called as:

Code: Select all

void std::sort(_RandomAccessIterator, _RandomAccessIterator, _Compare)

with _RandomAccessIterator = __gnu_cxx::__normal_iterator<PopCenter**, std::vector<PopCenter*, std::allocator<PopCenter*> > >

_Compare = bool (*)(PopCenter*&, PopCenter*&)]’
ie. it's passed normal (non-const) iterators to a vector of PopCenter*. Yet later the iterator seems to be giving const pointers:

Code: Select all

error: invalid initialization of reference of type ‘PopCenter*&’ from expression of type ‘PopCenter* const’
Could you try changing

Code: Select all

void PopulationPool::SetPopCenters(const std::vector<PopCenter*>& pop_center_vec)
to

Code: Select all

void PopulationPool::SetPopCenters(std::vector<PopCenter*>& pop_center_vec)
(ie. remove the const), and similarly change the header, and see if it compiles then? It compiles fine for me, so I can't really test changes...

User avatar
loonycyborg
Compilation Expert
Posts: 219
Joined: Thu Jul 06, 2006 10:30 pm
Location: Russia/Moscow

#55 Post by loonycyborg » Sun Sep 24, 2006 10:41 pm

I patched it in different way:

Code: Select all

ResourcePool.cpp, around line 116
-    bool PopCenterLess(PopCenter*& elem1, PopCenter*& elem2)
+    bool PopCenterLess(PopCenter* elem1, PopCenter* elem2)
Geoff the Medio, what compiler are you using? Even gcc-3.4.5 barfs on this code.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12519
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

#56 Post by Geoff the Medio » Sun Sep 24, 2006 10:55 pm

loonycyborg wrote:

Code: Select all

ResourcePool.cpp, around line 116
-    bool PopCenterLess(PopCenter*& elem1, PopCenter*& elem2)
+    bool PopCenterLess(PopCenter* elem1, PopCenter* elem2)
Works for me. I infer that it also works for you? If so, I'll upload to SVN...
Geoff the Medio, what compiler are you using? Even gcc-3.4.5 barfs on this code.
MSVC 8

User avatar
MareviQ
Space Kraken
Posts: 100
Joined: Tue Aug 09, 2005 6:47 pm
Location: Somewhere in Poland

#57 Post by MareviQ » Sun Sep 24, 2006 11:46 pm

yup, loonycyborgs modification did the trick. Now I can finally get back to work on the OpenAL implementation :) During my absence I more or less figured out how the music part can be done and how to fix the problems of the current version.

Post Reply