Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails with: google/api/http.pb.h: No such file or directory #37

Closed
ashish-billore opened this issue Feb 1, 2021 · 7 comments · Fixed by #41
Closed

Compilation fails with: google/api/http.pb.h: No such file or directory #37

ashish-billore opened this issue Feb 1, 2021 · 7 comments · Fixed by #41
Labels

Comments

@ashish-billore
Copy link
Contributor

ashish-billore commented Feb 1, 2021

I followed the instructions to build and install the etcd-cpp-apiv3 package on Ubuntu 18.04 following the steps:

Build and install completed successfully without errors.

After that I created a test program like this, following snippet from here

 ...
  etcd::Client etcd("http://127.0.0.1:2379");
  etcd::Response response = etcd.get("/test/key1").get();
  std::cout << response.value().as_string();
 ...

I try to compile like this:
g++ test.cpp -o test_etcd -lpthread -letcd-cpp-api -lprotobuf -lgrpc++ -lgrpc -lz -lcpprest -lssl -lcrypto -lboost_system

However, I get error like this:

In file included from /usr/local/include/etcd/proto/rpc.pb.h:34:0,
                 from /usr/local/include/etcd/proto/rpc.grpc.pb.h:7,
                 from /usr/local/include/etcd/Client.hpp:11,
                 from test.cpp:1:
/usr/local/include/etcd/proto/google/api/annotations.pb.h:28:10: fatal error: google/api/http.pb.h: No such file or directory
 #include "google/api/http.pb.h"
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I already installed proto and grpc libs and expected it to work, can anyone suggest what is missing here?

@ashish-billore
Copy link
Contributor Author

ashish-billore commented Feb 1, 2021

I see this file does exists, still build fails for not finding it:

root@lb-prof:~/etcd# ls -ltrh /usr/local/include/etcd/proto/google/api/http.pb.h
-rw-r--r-- 1 root root 61K Jan 31 21:44 /usr/local/include/etcd/proto/google/api/http.pb.h
root@lb-prof:~/etcd# 

I manually then updated the file:

`/usr/local/include/etcd/proto/google/api/annotations.pb.h'

as:

#include "http.pb.h" instead of original: #include "google/api/http.pb.h"

and then it compiled.

Wondering, if this is right way or expected while using etcd-cpp-apiv3 in any program.
Please suggest?

@sighingnow
Copy link
Member

Hi @ashish-billore,

Assuming you are installing etcd-cpp-apiv3 library into /usr/local, you need to add /usr/local/include as well as /usr/local/include/etcd to the compiler flags, as

g++ -I/usr/local/include -I/usr/local/include/etcd

That is a bit annoying, but the fixes is not very easy. We want to keep the same package name, module name and file structures with etcd ifself (that means, when we update protobuf files, we just need to copy them, without any changes). The include path in headers is generated by protoc, not ourself. I think adding a nother include directory should be usually fine enough.

@sighingnow
Copy link
Member

Wondering, if this is right way or expected while using etcd-cpp-apiv3 in any program.

Assuming you are working with CMake, you just need to add another include directory.

@ashish-billore
Copy link
Contributor Author

Thanks @sighingnow I'll follow your suggestion to compile with:

g++ -I/usr/local/include -I/usr/local/include/etcd

@sighingnow
Copy link
Member

Hi @ashish-billore,

I would like to know if providing a cmake module to make find_package(etcd) work and set a CMake variable ETCD_INCLUDE_DIRS helps for you case.

@ashish-billore
Copy link
Contributor Author

Sure, that sounds good too.

@ashish-billore
Copy link
Contributor Author

@sighingnow After compiling as above, when I try to run the application, I get a core dump.
I create another issue for that: #40 since the compilation is done.
Please have a look, thanks!

@sighingnow sighingnow added the bug label Feb 2, 2021
sighingnow added a commit to sighingnow/etcd-cpp-apiv3 that referenced this issue Feb 6, 2021
…uf/grpc files.

Add CMake config files to make it looks as a cmake module.

Fixes etcd-cpp-apiv3#37.

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
sighingnow added a commit to sighingnow/etcd-cpp-apiv3 that referenced this issue Feb 6, 2021
…uf/grpc files.

Add CMake config files to make it looks as a cmake module.

Fixes etcd-cpp-apiv3#37.

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
sighingnow added a commit to sighingnow/etcd-cpp-apiv3 that referenced this issue Feb 6, 2021
…uf/grpc files.

Add CMake config files to make it looks as a cmake module.

Fixes etcd-cpp-apiv3#37.

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
sighingnow added a commit that referenced this issue Feb 6, 2021
…uf/grpc files. (#41)

Add CMake config files to make it looks as a cmake module.

Fixes #37.

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants