compiler questions
Moderator: Oberlus
- loonycyborg
- Compilation Expert
- Posts: 219
- Joined: Thu Jul 06, 2006 10:30 pm
- Location: Russia/Moscow
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++.
- loonycyborg
- Compilation Expert
- Posts: 219
- Joined: Thu Jul 06, 2006 10:30 pm
- Location: Russia/Moscow
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.
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.
- loonycyborg
- Compilation Expert
- Posts: 219
- Joined: Thu Jul 06, 2006 10:30 pm
- Location: Russia/Moscow
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
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
I don't even see an error. It's a warning.
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...../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
Press any key to continue or any other key to cancel.
Can COWs fly?
Can COWs fly?
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:
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:
the error generated is
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
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'
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
}
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
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
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:
ie. it's passed normal (non-const) iterators to a vector of PopCenter*. Yet later the iterator seems to be giving const pointers:
Could you try changing
to
(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...
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*&)]’
Code: Select all
error: invalid initialization of reference of type ‘PopCenter*&’ from expression of type ‘PopCenter* const’
Code: Select all
void PopulationPool::SetPopCenters(const std::vector<PopCenter*>& pop_center_vec)
Code: Select all
void PopulationPool::SetPopCenters(std::vector<PopCenter*>& pop_center_vec)
- loonycyborg
- Compilation Expert
- Posts: 219
- Joined: Thu Jul 06, 2006 10:30 pm
- Location: Russia/Moscow
I patched it in different way:
Geoff the Medio, what compiler are you using? Even gcc-3.4.5 barfs on this code.
Code: Select all
ResourcePool.cpp, around line 116
- bool PopCenterLess(PopCenter*& elem1, PopCenter*& elem2)
+ bool PopCenterLess(PopCenter* elem1, PopCenter* elem2)
- Geoff the Medio
- Programming, Design, Admin
- Posts: 13587
- Joined: Wed Oct 08, 2003 1:33 am
- Location: Munich
Works for me. I infer that it also works for you? If so, I'll upload to SVN...loonycyborg wrote:Code: Select all
ResourcePool.cpp, around line 116 - bool PopCenterLess(PopCenter*& elem1, PopCenter*& elem2) + bool PopCenterLess(PopCenter* elem1, PopCenter* elem2)
MSVC 8Geoff the Medio, what compiler are you using? Even gcc-3.4.5 barfs on this code.