protobuf python无法找到包含

时间:2014-05-10 11:31:11

标签: python c++ linux python-2.7 protocol-buffers

我注意到其他一些人遇到了问题,我看到的解决方案只包括CXXFLAGSLDFLAGS,但那些似乎不起作用。

尝试使用virtualenv和用户帐户编译和安装在CentOS上的替代Python版本的C ++ protobuff:

$ cd ~/myApp
$ /opt/python-2.7/bin/virtualenv python
$ source ~/myApp/python/bin/activate
(python)$ cd ~/src/protobuf-2.5.0
(python)$ ./configure --prefix=$HOME/usr
(python)$ make && make install

向上弹出一条消息说:

  
     

已安装的库:      /家庭/为myuser / usr / lib中

     

如果您碰巧想要链接已安装的库   在给定目录LIBDIR中,您必须使用libtool和   指定库的完整路径名,或使用-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the LD_LIBRARY_PATH'环境变量        执行期间       - 将LIBDIR添加到LD_RUN_PATH' environment variable during linking - use the - Wl,-rpath -Wl,LIBDIR'链接器标志       - 让系统管理员将LIBDIR添加到`/etc/ld.so.conf'

好的,继续前进:

(python)$ export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp
(python)$ export CXXFLAGS=-I$HOME/usr/include
(python)$ export LDFLAGS=-L$HOME/usr/lib
(python)$ cd python
(python)$ python setup.py build

然后它退出:

Using EXPERIMENTAL C++ Implmenetation.
running build
running build_py
running build_ext
building 'google.protobuf.internal._net_proto2___python' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/opt/python-2.7/include/python2.7 -c google/protobuf/pyext/python_descriptor.cc -o build/temp.linux-x86_64-2.7/google/protobuf/pyext/python_descriptor.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
In file included from google/protobuf/pyext/python_descriptor.cc:36:
./google/protobuf/pyext/python_descriptor.h:39:40: error: google/protobuf/descriptor.h: No such file or directory
google/protobuf/pyext/python_descriptor.cc:37:43: error: google/protobuf/descriptor.pb.h: No such file or directory
In file included from google/protobuf/pyext/python_descriptor.cc:36:
./google/protobuf/pyext/python_descriptor.h:55: error: ISO C++ forbids declaration of ‘FieldDescriptor’ with no type
./google/protobuf/pyext/python_descriptor.h:55: error: invalid use of ‘::’
./google/protobuf/pyext/python_descriptor.h:55: error: expected ‘;’ before ‘*’ token
./google/protobuf/pyext/python_descriptor.h:81: error: expected constructor, destructor, or type conversion before ‘*’ token
google/protobuf/pyext/python_descriptor.cc:48: error: expected initializer before ‘*’ token
google/protobuf/pyext/python_descriptor.cc:93: warning: deprecated conversion from string constant to ‘char*’
google/protobuf/pyext/python_descriptor.cc:93: warning: deprecated conversion from string constant to ‘char*’
google/protobuf/pyext/python_descriptor.cc:93: warning: deprecated conversion from string constant to ‘char*’
google/protobuf/pyext/python_descriptor.cc:93: warning: deprecated conversion from string constant to ‘char*’
google/protobuf/pyext/python_descriptor.cc:93: warning: deprecated conversion from string constant to ‘char*’
google/protobuf/pyext/python_descriptor.cc:152: error: ISO C++ forbids declaration of ‘DescriptorPool’ with no type
google/protobuf/pyext/python_descriptor.cc:152: error: invalid use of ‘::’
google/protobuf/pyext/python_descriptor.cc:152: error: expected ‘;’ before ‘*’ token
google/protobuf/pyext/python_descriptor.cc:158: error: expected unqualified-id before ‘*’ token
google/protobuf/pyext/python_descriptor.cc:158: error: expected ‘)’ before ‘*’ token
google/protobuf/pyext/python_descriptor.cc:158: error: expected initializer before ‘*’ token
google/protobuf/pyext/python_descriptor.cc:337: error: expected ‘}’ at end of input
google/protobuf/pyext/python_descriptor.cc:337: error: expected ‘}’ at end of input
google/protobuf/pyext/python_descriptor.cc:337: error: expected ‘}’ at end of input
google/protobuf/pyext/python_descriptor.cc:155: warning: ‘void google::protobuf::python::CDescriptorPoolDealloc(google::protobuf::python::CDescriptorPool*)’ declared ‘static’ but never defined
error: command 'gcc' failed with exit status 1

1 个答案:

答案 0 :(得分:0)

似乎setuptools没有关注CXXFLAGS环境变量 - 您可以看到CXXFLAGS命令行中没有显示gcc。考虑到它使用gcc而不是g++,它似乎甚至不知道它正在编译C ++。请尝试使用CFLAGS