Jump to content
XCOMUFO & Xenocide

Problems Compiling On 64 Bit Linux


Shifty Dave

Recommended Posts

Hi,

 

I've posted this question here, because I figure it's more of a development issue. It seems that the bug reporting web page is dead, so I can't check if this is an existing bug. I am attempting to compile this under Suse 10.1 (yeah I know it's a beta, but I don't think that's the reason for the problem) for AMD64. This is gcc 4, if that makes a difference.

 

Firstly, there are some problems in some of the header files:

 

src/position.h:22: error: extra qualification ‘Position::’ on member ‘index’

src/server.h:56: error: extra qualification ‘ClientServer::’ on member ‘connect’

make: *** [obj/bullet.o] Error 1

 

Which are quite easily fixed by removing the qualifiers. There is a similar problem in random.h, can't remember the exact message at this moment.

 

There are also the following compile erros, which seem less trivial to fix:

 

g++ -MMD -funsigned-char -Wall -Wno-deprecated-declarations -I src/lua -I src/luasqlite3 -DDEBUGMODE -DUFO_SVNVERSION=\"exported\" -O2 -pipe -I/usr/include/freetype2 -DHAVE_FREETYPE -DGLYPH_TARGET=GLYPH_TARGET_ALLEGRO -DGK_NO_LEGACY -DHAVE_PNG -DLINUX -I/usr/local/include -c src/sound.cpp -o obj/sound.o

src/sound.cpp: In function ‘SAMPLE* wav2sample(const std::string&, std::ostream&, bool)’:

src/sound.cpp:383: error: cast from ‘SAMPLE*’ to ‘int’ loses precision

src/sound.cpp: In function ‘void h_StartEl(void*, const XML_Char*, const XML_Char**)’:

src/sound.cpp:755: error: cast from ‘SAMPLE*’ to ‘int’ loses precision

make: *** [obj/sound.o] Error 1

 

g++ -MMD -funsigned-char -Wall -Wno-deprecated-declarations -I src/lua -I src/luasqlite3 -DDEBUGMODE -DUFO_SVNVERSION=\"exported\" -O2 -pipe -I/usr/include/freetype2 -DHAVE_FREETYPE -DGLYPH_TARGET=GLYPH_TARGET_ALLEGRO -DGK_NO_LEGACY -DHAVE_DUMBOGG -DHAVE_PNG -DLINUX -I/usr/local/include -c src/sound.cpp -o obj/sound.o

src/sound.cpp: In function ‘SAMPLE* wav2sample(const std::string&, std::ostream&, bool)’:

src/sound.cpp:383: error: cast from ‘SAMPLE*’ to ‘int’ loses precision

src/sound.cpp: In function ‘void h_StartEl(void*, const XML_Char*, const XML_Char**)’:

src/sound.cpp:755: error: cast from ‘SAMPLE*’ to ‘int’ loses precision

make: *** [obj/sound.o] Error 1

 

It seems that the code is typecasting pointers to integers. I think that this is problematic in 64 bit x86 mode because pointers are now 64 bit, while ints are still 32 bit.

 

Any thoughts on how to get around these problems? Are there some switches to tell g++ to ignore these errors?

 

cheers

 

Dave

Link to comment
Share on other sites

Hmm, well I should have been a bit less lazy before I posted. It seems that the lines in question are just printing out the pointer in the case of an error. It seems that chaning this to a long long solves the problem. With the no_dumbogg=1 option, I managed to compile fully.
Link to comment
Share on other sites

Well, I got it working in the end. For anyone who's interested, here's the patch that I used to fix the problems, and hopefully haven't caused any others.

 

I defined a new type "print_pointer", which is a long long on x86_64 platform, otherwise is an int

 

I incorporated this type into the places where pointers are being printed (3 header files)

 

I got rid of redundant qualifiers which caused problems for g++ (Is there any reason why these might be needed on any other platform?)

 

In the file gui.h, I swapped the order of declaration of the classes SkinInterface and SkinFeature, because SkinInterface contains a pointer to SkinFeature, so g++ wants it to be declared afterwards.

 

As for problems with DUMB, it was just the wrong version, doh!

 

Index: src/global.h
===================================================================
--- src/global.h        (revision 1027)
+++ src/global.h        (working copy)
@@ -98,6 +98,12 @@
#error Can not define int32 type
#endif

+#ifdef __x86_64__
+typedef long long print_pointer;
+#else
+typedef int print_pointer;
+#endif
+
inline uint16 intel_uint16(uint16 x)
{
#ifdef ALLEGRO_BIG_ENDIAN
Index: src/sound.cpp
===================================================================
--- src/sound.cpp       (revision 1027)
+++ src/sound.cpp       (working copy)
@@ -380,7 +380,7 @@
        }
    }
    if (verbose)
-        log<<"returning SAMPLE pointer 0x"<<std::hex<<(int)spl
+        log<<"returning SAMPLE pointer 0x"<<std::hex<<(print_pointer)spl
           <<std::dec<<std::endl;
    return spl;
}
@@ -752,7 +752,7 @@
        b->zeSys->setSample(soundSym, sample);
        b->curSample = sample;
        if (b->verbose)
-            *b->log<<"assigned 0x"<<std::hex<<(int)sample<<std::dec<<" to '"<<sym<<"'\n";
+            *b->log<<"assigned 0x"<<std::hex<<(print_pointer)sample<<std::dec<<" to '"<<sym<<"'\n";
        return;
    }

Index: src/gui.h
===================================================================
--- src/gui.h   (revision 1027)
+++ src/gui.h   (working copy)
@@ -28,38 +28,6 @@
#include "global.h"
#include "sprite.h"

-/*class SkinInterface;*/
-/**
- * SkinInterface object. Reaches for properties defined in standard-gui.lua
- * Used to get GUI related properties such as window placement, fonts, images, button sizes, etc.
- * -- globals used --
- * SCREEN_H, SCREEN_W
- * -- Usage --
- * gui = new SkinInterface();
- * gui->function( params );
- * gui->Feature( feature name )->function( params );
- */
-class SkinInterface
-{
-private:
-    friend class SkinFeature;
-
-    ALPHA_SPRITE *m_background;
-    const char *m_screen;
-    /*  Returns values from the screen itself (Screen) */
-    ALPHA_SPRITE *get_bitmap(const char *bitmap_name);
-public:
-    SkinInterface();
-    SkinInterface(const char *screen_name);
-    ~SkinInterface();
-    /*  - Feature subclass */
-    SkinFeature *Feature(const char *feature_name);
-    /*  - Background related properties */
-    BITMAP *background();
-    /*  - Other properties */
-    const char *name() { return m_screen; };
-};
-
/*class SkinFeature;*/
/**
 * SkinFeature object. Reaches for properties of a screen feature defined in standard-gui.lua
@@ -107,4 +75,36 @@
    const char *name() { return m_feature; };
};

+/*class SkinInterface;*/
+/**
+ * SkinInterface object. Reaches for properties defined in standard-gui.lua
+ * Used to get GUI related properties such as window placement, fonts, images, button sizes, etc.
+ * -- globals used --
+ * SCREEN_H, SCREEN_W
+ * -- Usage --
+ * gui = new SkinInterface();
+ * gui->function( params );
+ * gui->Feature( feature name )->function( params );
+ */
+class SkinInterface
+{
+private:
+    friend class SkinFeature;
+
+    ALPHA_SPRITE *m_background;
+    const char *m_screen;
+    /*  Returns values from the screen itself (Screen) */
+    ALPHA_SPRITE *get_bitmap(const char *bitmap_name);
+public:
+    SkinInterface();
+    SkinInterface(const char *screen_name);
+    ~SkinInterface();
+    /*  - Feature subclass */
+    SkinFeature *Feature(const char *feature_name);
+    /*  - Background related properties */
+    BITMAP *background();
+    /*  - Other properties */
+    const char *name() { return m_screen; };
+};
+
#endif
Index: src/position.h
===================================================================
--- src/position.h      (revision 1027)
+++ src/position.h      (working copy)
@@ -19,7 +19,7 @@
    int level() {return m_pos >> 16;}
    int column() {return (m_pos >> 8) & 255;}
    int row() {return m_pos & 255;}
-    int Position::index();
+    int index();
    int32 position() {return m_pos;}
    Position operator= (const Position pos){ m_pos = pos.m_pos; return pos; }
    bool operator== (const Position& pos){ return m_pos == pos.m_pos; }
Index: src/server.h
===================================================================
--- src/server.h        (revision 1027)
+++ src/server.h        (working copy)
@@ -49,7 +49,7 @@
    NLsocket    m_socket;
public:
    virtual ~ClientServer();
-    bool ClientServer::connect(
+    bool connect(
        const std::string &host,
        const std::string &proxy,
        const std::string &proxy_login,
Index: src/random.h
===================================================================
--- src/random.h        (revision 1027)
+++ src/random.h        (working copy)
@@ -40,7 +40,7 @@
    long m_j, m_k, m_init, m_iters;
    REAL m_normalsaved;
    bool m_iff, m_normalready;
-    void Random::next() {
+    void next() {
        ASSERT (m_iff);
        if (++m_inext == 56) m_inext = 1;
        if (++m_inextp == 56) m_inextp = 1;

Link to comment
Share on other sites

Well, I got it working in the end.  For anyone who's interested, here's the patch that I used to fix the problems, and hopefully haven't caused any others. 

 

I defined a new type "print_pointer", which is a long long on x86_64 platform, otherwise is an int

 

I incorporated this type into the places where pointers are being printed (3 header files)

 

I got rid of redundant qualifiers which caused problems for g++ (Is there any reason why these might be needed on any other platform?)

 

In the file gui.h, I swapped the order of declaration of the classes SkinInterface and SkinFeature, because SkinInterface contains a pointer to SkinFeature, so g++ wants it to be declared afterwards.

Thanks for your feedback =b The source of these problems is that gcc gets more strict with every new version. Can you provide exact gcc version for a proper changelog entry?

 

As for problems with DUMB, it was just the wrong version, doh!

Yes, that's rather unfortunate. For this reason most of less known/often breaking compatibility libraroes are already integrated in ufo2000 sources tree (subdirectories in 'src' directory). I gues we will need to do something with this DUMB library too.

Link to comment
Share on other sites

Fix committed in revision 1028. As the forum is not the very best place for patches (tabs/spaces got probably mesed and the patch refused to apply), the changes from the patch were applied manually. So please check if everything is ok now.

 

PS. bugtracker is available now

Link to comment
Share on other sites

Fix committed in revision 1028. As the forum is not the very best place for patches (tabs/spaces got probably mesed and the patch refused to apply), the changes from the patch were applied manually. So please check if everything is ok now.

 

PS. bugtracker is available now

 

I reverted my local copy, and updated to 1028. It compiles and runs fine.

 

If the forum isn't very good, how would you suggest that people such as myself without commit access should send any future patches?

Link to comment
Share on other sites

I reverted my local copy, and updated to 1028.  It compiles and runs fine.

ok, thanks

 

If the forum isn't very good, how would you suggest that people such as myself without commit access should send any future patches?

Well, if a patch is attached as file either here in the forum or in the bugtracker, that should be ok. Just pasting it in the message body seems to result in a malformed patch.

 

Thanks again for your feedback.

 

PS. Tried to install gcc 4.1.0 in my gentoo linux, but it requires to switch to glibc version which is marked unstable currently in this distro, so I'll wait a bit more and we'll have to rely on your feedback if anything gets broken again :)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...