Skip to main content
 首页 » 编程设计

python之cryptopp 错误 : expected '=' , ','、 ';'、 'asm' 或 '__attribute__' token 之前的 '{'

2024年10月25日29linjiqin

我添加了一个安全模块,它需要安装 cryptopp,它是用 C 语言编写的,包含以下内容:

#include <Python.h> 
#include <common/credentials.h> 
#include "proto/security.pb.h" 
#include <string.h> 

我用谷歌搜索了错误并验证了 Python.h header 存在,-I/usr/include/python2.6 出现在 make 中,python-devel-2.6.6-52.el6.x86_64软件包已安装。我错过了一面旗帜吗?是“命名空间”还是解析错误?

g++ -o /home/build/workarea/1.0.0/build_fileclient/baseutils/src/cc/unixusergrouphelper.os -c -g -Wall -isystem/usr/local/protobuf-2.5.0//include -O2 -pthread -fPIC -fPIC -I/home/build/workarea/1.0.0/build_fileclient -I. -I/usr/include -I/usr/local/protobuf-2.5.0/include -I/home/build/workarea/1.0.0/build_fileclient/fs -Ifs -I/home/build/workarea/1.0.0/build_fileclient/fs/common/gperftools/src -Ifs/common/gperftools/src -I/home/build/workarea/1.0.0/build_fileclient/fs/server -Ifs/server -I/home/build/workarea/1.0.0/build_fileclient/fs/client -Ifs/client -I/usr/local/java/include -I/usr/local/java/include/linux -I/usr/include/python2.6 -I/home/build/workarea/1.0.0/build_fileclient/fs/client/fileclient/java/fs-jni/target/native/javah -Ifs/client/fileclient/java/fs-jni/target/native/javah -I/home/build/workarea/1.0.0/build_version -I/home/build/workarea/github/dl/hadoop-common/hadoop-hdfs-project/hadoop-hdfs -I/home/build/workarea/github/dl/hadoop-common/hadoop-hdfs-project/hadoop-hdfs/target/native baseutils/src/cc/unixusergrouphelper.cc 
In file included from /usr/include/cryptopp/osrng.h:6:0, 
                 from fs/common/credentials.h:6, 
                 from baseutils/src/cc/securitymodule.c:2: 
/usr/include/cryptopp/config.h:97:1: error: unknown type name 'namespace' 
/usr/include/cryptopp/config.h:97:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token 
In file included from /usr/include/cryptopp/cryptlib.h:83:0, 
                 from /usr/include/cryptopp/randpool.h:4, 
                 from /usr/include/cryptopp/osrng.h:10, 
                 from fs/common/credentials.h:6, 
                 from baseutils/src/cc/securitymodule.c:2: 
/usr/include/cryptopp/stdcpp.h:14:18: fatal error: memory: No such file or directory 
compilation terminated. 
In file included from /usr/include/cryptopp/osrng.h:6:0, 
                 from fs/common/credentials.h:6, 
                 from baseutils/src/cc/securitymodule.c:2: 
/usr/include/cryptopp/config.h:97:1: error: unknown type name 'namespace' 
/usr/include/cryptopp/config.h:97:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token 
In file included from /usr/include/cryptopp/cryptlib.h:83:0, 
                 from /usr/include/cryptopp/randpool.h:4, 
                 from /usr/include/cryptopp/osrng.h:10, 
                 from fs/common/credentials.h:6, 
                 from baseutils/src/cc/securitymodule.c:2: 
/usr/include/cryptopp/stdcpp.h:14:18: fatal error: memory: No such file or directory 
compilation terminated. 

请您参考如下方法:

GCC 根据文件名的后缀决定用什么语言编写文件。将文件重命名为 *.cc 或 *.cpp,或将 -x c++ 传递给 g++。