编译mpeg4ip会给出解除引用类型的指针错误

时间:2013-10-31 05:55:31

标签: c++ c

我正在尝试在Linux机器上编译mpeg4ip(Redhat 9)并且我遇到了很多错误,因为它显然不再受支持了。这是我得到的错误:

make[5]: Entering directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib/rtp'
if /bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.    -DDEBUG -Wall -Werror -g -O2 -Wall -Werror -W  -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wwrite-strings -Wformat=2 -MT rijndael-alg-fst.lo -MD -MP -MF ".deps/rijndael-alg-fst.Tpo" -c -o rijndael-alg-fst.lo rijndael-alg-fst.c; \
then mv -f ".deps/rijndael-alg-fst.Tpo" ".deps/rijndael-alg-fst.Plo"; else rm -f ".deps/rijndael-alg-fst.Tpo"; exit 1; fi
 gcc -DHAVE_CONFIG_H -I. -I. -I. -DDEBUG -Wall -Werror -g -O2 -Wall -Werror -W -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -Wwrite-strings -Wformat=2 -MT rijndael-alg-fst.lo -MD -MP -MF .deps/rijndael-alg-fst.Tpo -c rijndael-alg-fst.c  -fPIC -DPIC -o .libs/rijndael-alg-fst.o
cc1: warnings being treated as errors
rijndael-alg-fst.c: In function 'rijndaelEncrypt':
rijndael-alg-fst.c:126: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c:147: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c:170: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c: In function 'rijndaelDecrypt':
rijndael-alg-fst.c:274: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c:296: error: dereferencing type-punned pointer will break strict-aliasing rules
rijndael-alg-fst.c:318: error: dereferencing type-punned pointer will break strict-aliasing rules
make[5]: *** [rijndael-alg-fst.lo] Error 1
make[5]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib/rtp'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib/rtp'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib/rtp'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ec2-user/mpeg4ip-1.5.0.1'
make: *** [all] Error 2

违规方法(或至少其中一种)是:

int rijndaelEncrypt(word8 a[16], word8 b[16], word8 rk[MAXROUNDS+1][4][4], int ROUNDS) {
    int r;
    word8 temp[4][4];

*((word32*)temp[0]) = *((word32*)(a   )) ^ *((word32*)rk[0][0]);
*((word32*)temp[1]) = *((word32*)(a+ 4)) ^ *((word32*)rk[0][1]);
*((word32*)temp[2]) = *((word32*)(a+ 8)) ^ *((word32*)rk[0][2]);
*((word32*)temp[3]) = *((word32*)(a+12)) ^ *((word32*)rk[0][3]);
*((word32*)(b    )) = *((word32*)T1[temp[0][0]])
                                            ^ *((word32*)T2[temp[1][1]])
                                            ^ *((word32*)T3[temp[2][2]])
                                            ^ *((word32*)T4[temp[3][3]]);
*((word32*)(b + 4)) = *((word32*)T1[temp[1][0]])
                                            ^ *((word32*)T2[temp[2][1]])
                                            ^ *((word32*)T3[temp[3][2]])
                                            ^ *((word32*)T4[temp[0][3]]);
*((word32*)(b + 8)) = *((word32*)T1[temp[2][0]])
                                            ^ *((word32*)T2[temp[3][1]])
                                            ^ *((word32*)T3[temp[0][2]])
                                            ^ *((word32*)T4[temp[1][3]]);
*((word32*)(b +12)) = *((word32*)T1[temp[3][0]])
                                            ^ *((word32*)T2[temp[0][1]])
                                            ^ *((word32*)T3[temp[1][2]])
                                            ^ *((word32*)T4[temp[2][3]]);
    for (r = 1; r < ROUNDS-1; r++) {
            *((word32*)temp[0]) = *((word32*)(b   )) ^ *((word32*)rk[r][0]);
            *((word32*)temp[1]) = *((word32*)(b+ 4)) ^ *((word32*)rk[r][1]);
            *((word32*)temp[2]) = *((word32*)(b+ 8)) ^ *((word32*)rk[r][2]);
            *((word32*)temp[3]) = *((word32*)(b+12)) ^ *((word32*)rk[r][3]);

            *((word32*)(b    )) = *((word32*)T1[temp[0][0]])
                                                    ^ *((word32*)T2[temp[1][1]])
                                                    ^ *((word32*)T3[temp[2][2]])
                                                    ^ *((word32*)T4[temp[3][3]]);
            *((word32*)(b + 4)) = *((word32*)T1[temp[1][0]])
                                                    ^ *((word32*)T2[temp[2][1]])
                                                    ^ *((word32*)T3[temp[3][2]])
                                                    ^ *((word32*)T4[temp[0][3]]);
            *((word32*)(b + 8)) = *((word32*)T1[temp[2][0]])
                                                    ^ *((word32*)T2[temp[3][1]])
                                                    ^ *((word32*)T3[temp[0][2]])
                                                    ^ *((word32*)T4[temp[1][3]]);
            *((word32*)(b +12)) = *((word32*)T1[temp[3][0]])
                                                    ^ *((word32*)T2[temp[0][1]])
                                                    ^ *((word32*)T3[temp[1][2]])
                                                    ^ *((word32*)T4[temp[2][3]]);
    }
    /* last round is special */
    *((word32*)temp[0]) = *((word32*)(b   )) ^ *((word32*)rk[ROUNDS-1][0]);
    *((word32*)temp[1]) = *((word32*)(b+ 4)) ^ *((word32*)rk[ROUNDS-1][1]);
    *((word32*)temp[2]) = *((word32*)(b+ 8)) ^ *((word32*)rk[ROUNDS-1][2]);
    *((word32*)temp[3]) = *((word32*)(b+12)) ^ *((word32*)rk[ROUNDS-1][3]);
    b[ 0] = T1[temp[0][0]][1];
    b[ 1] = T1[temp[1][1]][1];
    b[ 2] = T1[temp[2][2]][1];
    b[ 3] = T1[temp[3][3]][1];
    b[ 4] = T1[temp[1][0]][1];
    b[ 5] = T1[temp[2][1]][1];
    b[ 6] = T1[temp[3][2]][1];
    b[ 7] = T1[temp[0][3]][1];
    b[ 8] = T1[temp[2][0]][1];
    b[ 9] = T1[temp[3][1]][1];
    b[10] = T1[temp[0][2]][1];
    b[11] = T1[temp[1][3]][1];
    b[12] = T1[temp[3][0]][1];
    b[13] = T1[temp[0][1]][1];
    b[14] = T1[temp[1][2]][1];
    b[15] = T1[temp[2][3]][1];
    *((word32*)(b   )) ^= *((word32*)rk[ROUNDS][0]);
    *((word32*)(b+ 4)) ^= *((word32*)rk[ROUNDS][1]);
    *((word32*)(b+ 8)) ^= *((word32*)rk[ROUNDS][2]);
    *((word32*)(b+12)) ^= *((word32*)rk[ROUNDS][3]);

    return 0;
}

有人可以告诉我如何解决这个问题吗?我已经在网上找到了这个文件的更新版本(版本3),但是当我尝试实现它时,我得到的错误多于你可以动摇一下。提前谢谢。

1 个答案:

答案 0 :(得分:0)

下载最新的源代码(mpeg4ip-1.6.1版本)

ftp://ftp.netbsd.org/pub/pkgsrc/distfiles/mpeg4ip-1.6.1.tar.gz

(如果出现错误,请注释include / mpeg4ip.h的第126行)

make and make install