犯错误 - ec_asn1.o - ec_asn1.c:201:错误:在' X9_62_PENTANOMIAL'之前的预期表达式

时间:2015-01-30 19:35:26

标签: linux redhat openssl

我正在尝试在Red Hat上安装单独版本的Openssl 1.0.1k。我首先尝试使用Centos,没有任何实际问题。

在发生此错误之前,我执行了以下操作:

yum install -y libxml2 libxml2-devel libxslt libxslt-devel    #not sure if this actually helped with my errors. 
./config --prefix=/data/home/jboss/openssl_1.0.1/usr         \
         --openssldir=/data/home/jboss/openssl_1.0.1/etc/ssl
# missing include files. 
vi ~/.bash_profile
C_INCLUDE_PATH=/usr/lib/bcc/include/
CPLUS_INCLUDE_PATH=/usr/lib/bcc/include/
export C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH
LANG=en_US           # make was giving accented a special characters. This fixed. I would set it back once I fixed to en_US.UTF-8. 
vi /usr/lib/bcc/include/asm/limits.h
define INT_MAX              2147483647

毕竟,我得到以下内容:

.... more on top
make[2]: Entering directory `/data01/home/s617741/openssl-1.0.1k/crypto/bn'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/data01/home/s617741/openssl-1.0.1k/crypto/bn'
making all in crypto/ec...
make[2]: Entering directory `/data01/home/s617741/openssl-1.0.1k/crypto/ec'
gcc -I.. -I../.. -I../modes -I../asn1 -I../evp -I../../include  -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack -m64 -DL_ENDIAN -DTERMIO -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM   -c -o ec_asn1.o ec_asn1.c
ec_asn1.c:201: warning: implicit declaration of function 'offsetof'
ec_asn1.c:201: error: expected expression before 'X9_62_PENTANOMIAL'
ec_asn1.c:201: error: initializer element is not constant
ec_asn1.c:201: error: (near initialization for 'X9_62_PENTANOMIAL_seq_tt[0].offset')
ec_asn1.c:202: error: expected expression before 'X9_62_PENTANOMIAL'
ec_asn1.c:202: error: initializer element is not constant
ec_asn1.c:202: error: (near initialization for 'X9_62_PENTANOMIAL_seq_tt[1].offset')
ec_asn1.c:203: error: expected expression before 'X9_62_PENTANOMIAL'
ec_asn1.c:203: error: initializer element is not constant
ec_asn1.c:203: error: (near initialization for 'X9_62_PENTANOMIAL_seq_tt[2].offset')
... continues with similar errors. 

任何见解都会有所帮助。

1 个答案:

答案 0 :(得分:2)

{p> offsetof定义在<stddef.h>中,由ec_asn1.crand_egd.c使用。

但是,ec_asn1.crand_egd.c不包括<stddef.h>

$ cd openssl-1.0.1
$ find . -iname ec_asn1.c
./crypto/ec/ec_asn1.c
$ cat crypto/ec/ec_asn1.c | grep stddef

您应该打开ec_asn1.crand_egd.c,然后添加#include <stddef.h>

-----

针对此问题针对OpenSSL提交了一个错误:Bug 3684: Missing <stddef.h> for source files using offsetof。您可以在RT Tracker中查看状态。用username = guest,password = guest登录。

-----

以下是我正在处理的机器的定义,以备不时之需:

#if defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 5 || __GNUC__ > 3)
#ifndef __offsetof      /* Deprecated: for source compatibility only */
#define __offsetof(type, field) __builtin_offsetof(type, field)
#endif
#define offsetof(type, field) __builtin_offsetof(type, field)
#else /* ! (gcc >= 3.5) */
#ifndef __offsetof      /* Deprecated: for source compatibility only */
#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
#endif
#define offsetof(type, field) ((size_t)(&((type *)0)->field))
#endif /* (gcc >= 3.5) */