链接gRPC和FUSE文件时出现未定义的参考错误

时间:2019-07-21 22:55:32

标签: c++ g++ grpc fuse

我正在学习FUSE和gRPC库,并且正在使用FUSE直通示例:https://github.com/libfuse/libfuse/blob/master/example/passthrough.c

由于gRPC库位于C ++中,所以我切换到使用以下FUSE C ++包装器:https://github.com/jachappell/Fusepp

我正在尝试将传递示例应用于客户端/服务器模型。我的目标是在FUSE代码中进行RPC调用,以便在客户端调用的函数将在服务器端远程应用。

我编写了一个Client类(在passthrough.cpp文件中定义),在其中使用gRPC进行远程过程调用。我在FUSE passthrough.cc文件内创建此类的实例,并调用gRPC服务(通过Client类的成员函数)。

例如,以下是直通文件中的xmp_mkdir函数,并做了我的修改:

int Passthrough::xmp_mkdir(const char *path, mode_t mode)
{
    int res;

    Client client = Client();
    res = client.RPC_mkdir(path, mode);

    if (res == -1)
        return -errno;

    return 0;
}

Client::RPC_mkdir()函数仅调用gRPC服务,该服务发送服务器期望接收的必要参数。

编译文件时,将返回collect2: error: ld returned 1 exit status以及与此类似的错误列表:

/usr/bin/ld: cpp_passthrough.o: in function "Passthrough::pst_mkdir(char const*, unsigned int)": cpp_passthrough.cpp:(.text+0x3f7): undefined reference to grpc::InsecureChannelCredentials()'

我尝试过的编译命令如下:

  

protoc -I。 --grpc_out =。 --plugin = protoc-gen-grpc = which grpc_cpp_plugin passthrough.proto

     

protoc -I。 --cpp_out =。 passthrough.proto

     

g ++ -std = c ++ 11 pkg-config --cflags protobuf grpc -c -o passthrough.pb.o passthrough.pb.cc

     

g ++ -std = c ++ 11 pkg-config --cflags protobuf grpc -c -o passthrough.grpc.pb.o passthrough.grpc.pb.cc

     

g ++ -c -Wall -fpermissive --std = c ++ 14 pkg-config fuse3 --cflags -I .. cpp_passthrough.cpp -o cpp_passthrough.o

     

g ++ -c -fpermissive -I .. -I / usr / include / fuse3 cpp_passthrough_main.cpp -o cpp_passthrough_main.o

     

g ++ cpp_passthrough.o passthrough.grpc.pb.o passthrough.pb.o cpp_passthrough_main.o pkg-config fuse3 --libs -o passthrough

以及这些命令的变体。

由于我是g ++的新手,所以我真的不知道是什么导致了该问题或如何解决该问题。我将不胜感激。

0 个答案:

没有答案