xiaoyin0208 / lz4

Automatically exported from code.google.com/p/lz4
0 stars 0 forks source link

Compile errors on ubuntu 8.04 #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use ubuntu 8.04 with gcc (gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4))
2. Just run make

I use sources from svn on ubuntu 8.04. I use gcc 4.2.4, but that don't have 
__builtin_bswap32. And i have errors after run make.

gcc      -O3 -I. -std=c99 -Wall -W -Wundef -Wno-implicit-function-declaration 
lz4hc.c lz4.c bench.c lz4demo.c -o lz4demo64
/tmp/ccqSPzan.o: In function `decode_file':
lz4demo.c:(.text+0x3dd): undefined reference to `__builtin_bswap32'
lz4demo.c:(.text+0x468): undefined reference to `__builtin_bswap32'
/tmp/ccqSPzan.o: In function `compress_file':
lz4demo.c:(.text+0x756): undefined reference to `__builtin_bswap32'
lz4demo.c:(.text+0x771): undefined reference to `__builtin_bswap32'
lz4demo.c:(.text+0x7ae): undefined reference to `__builtin_bswap32'
collect2: ld returned 1 exit status
make: *** [lz4demo64] Error 1

I have patched your sources for fix that problem.

--- lz4demo.c   (revision 67)
+++ lz4demo.c   (working copy)
@@ -58,8 +58,13 @@
 #if defined(_MSC_VER)    // Visual Studio
 #define swap32 _byteswap_ulong
 #elif GCC_VERSION >= 402
+#include <byteswap.h>
+#if defined(__builtin_bswap32)
 #define swap32 __builtin_bswap32
 #else
+#define swap32 __bswap_32
+#endif
+#else

Original issue reported on code.google.com by Pervushi...@gmail.com on 9 Jun 2012 at 8:10

GoogleCodeExporter commented 8 years ago
Thanks. This looks clear and well defined.

I'm aware that <byteswap.h> is not always present on target platforms.
This dependancy must be used with a bit of caution.

Original comment by yann.col...@gmail.com on 10 Jun 2012 at 2:05

GoogleCodeExporter commented 8 years ago
Yes. My patch with <byteswap.h> not works on my mac with gcc version 4.2.1 
(Apple Inc. build 5666) (dot 3).

Here i saw comment with __builtin_bswapX is only available from GCC-4.3

http://stackoverflow.com/questions/105252/how-do-i-convert-between-big-endian-an
d-little-endian-values-in-c 

On that case patch can be very simple

Index: lz4demo.c
===================================================================
--- lz4demo.c   (revision 67)
+++ lz4demo.c   (working copy)
@@ -57,7 +57,7 @@

 #if defined(_MSC_VER)    // Visual Studio
 #define swap32 _byteswap_ulong
-#elif GCC_VERSION >= 402
+#elif GCC_VERSION >= 430
 #define swap32 __builtin_bswap32
 #else
 static inline unsigned int swap32(unsigned int x) {

Original comment by Pervushi...@gmail.com on 15 Jun 2012 at 8:56

GoogleCodeExporter commented 8 years ago
Simple and straightforward. Issue is corrected into r68. Thanks for 
notification !

Original comment by yann.col...@gmail.com on 16 Jun 2012 at 12:06