Zhe*_*ehZ 11 c++ linux compiler-errors g++ protocol-buffers
我寻求其他主题,但他们不帮我=(.在我的工作服务器上,我没有sudo特权,所以我安装PB与
./configure --prefix =/home/username/local
然后我用"person"示例创建源文件,并使用protoc成功编译它.
我没有pkg-info =(.我尝试用它编译它
g ++ -I/home/username/local/include -L/home/username/local/lib -lprotobuf -lpthread main.cpp person.pb.cc
然后有十亿个类似错误,即
person.pb.cc:(.text+0x4cf):未定义引用`google :: protobuf :: internal :: kEmptyString'
我认为,这是一个链接问题,但如何解决呢?
echo $ LD_LIBRARY_PATH/home/username/local/lib
在main.cpp中:
#include "person.pb.h"
...
Run Code Online (Sandbox Code Playgroud)
谢谢.
hmj*_*mjd 21
把图书馆放在最后:
g ++ -I/home/username/local/include -L/home/username/local/lib main.cpp person.pb.cc -lprotobuf -pthread
来自GCC链接选项:
-llibrary
-l library
Search the library named library when linking.
(The second alternative with the library as a separate argument
is only for POSIX compliance and is not recommended.)
It makes a difference where in the command you write this option;
the linker searches and processes libraries and object files in the
order they are specified.
Thus, `foo.o -lz bar.o' searches library `z' after file foo.o but
before bar.o. If bar.o refers to functions in `z', those functions
may not be loaded.
此外,使用-pthread,而不是-lpthread作为-pthread可用于预处理器和连接设置标志.
| 归档时间: |
|
| 查看次数: |
32196 次 |
| 最近记录: |