Skip to content

Compiling Error after 0.14 and a simple fix #7298

@pgrosu

Description

@pgrosu

Hi gRPC Team,

I performed the following steps after the 0.14 merge (#7219):

$ git clone https://github.com/grpc/grpc.git
$ cd grpc
$ git submodule update --init
$ make
$ git clone https://github.com/googleapis/googleapis
$ cd googleapis
$ make all
$ cd gens
$ g++ -c -std=c++11 -I/home/pgrosu/apps/protobuf/include -I../../include -I. ./google/genomics/v1/*cc
$ g++ -c -std=c++11 -I/home/pgrosu/apps/protobuf/include -I../../include -I. ./google/api/*cc
$ g++ -c -std=c++11 -I/home/pgrosu/apps/protobuf/include -I../../include -I. ./google/longrunning/*cc
$ g++ -c -std=c++11 -I/home/pgrosu/apps/protobuf/include -I../../include -I. ./google/rpc/*cc
$ g++ -c -std=c++11 -I/home/pgrosu/apps/protobuf/include -I../../include -I. ./google/iam/v1/*cc
$ cd ..

Then using the following client.cc code (referenced in #7131 (comment)):

#include <google/genomics/v1/reads.grpc.pb.h>
#include <grpc++/client_context.h>
#include <grpc++/create_channel.h>
#include <grpc++/security/credentials.h>
#include <grpc++/support/status.h>
#include <grpc/grpc.h>
#include <iostream>

int main(int argc, char** argv) {
  auto stub = ::google::genomics::v1::ReadServiceV1::NewStub(
      ::grpc::CreateChannel("genomics.googleapis.com:443",
                          ::grpc::GoogleDefaultCredentials()));

  ::grpc::ClientContext context;

  ::google::genomics::v1::SearchReadsRequest request;
  ::google::genomics::v1::SearchReadsResponse response;

  request.add_read_group_set_ids("CMvnhpKTFhDq9e2Yy9G-Bg");
  request.set_reference_name("17");
  request.set_start(41196311);
  request.set_end(41277499);

  stub->SearchReads(&context, request, &response);

  std::cout << "The Read ID is: " << response.alignments(0).id() << std::endl;
  std::cout << "The Fragment Name is: " << response.alignments(0).fragment_name() << std::endl;
  std::cout << "The Aligned Sequence is: " << response.alignments(0).aligned_sequence() << std::endl;

  std::cout << std::endl;

  return 0;
}

I then proceeded to try and compile it like this:

$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:../libs/opt:../libs/opt/protobuf:/home/pgrosu/apps/protobuf/lib
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/pgrosu/apps/protobuf/lib
$ export GRPC_DEFAULT_SSL_ROOTS_FILE_PATH=/home/pgrosu/apps/grpc/etc/roots.pem
$ export GOOGLE_APPLICATION_CREDENTIALS=ya...[my access token]...
$
$ g++ -std=c++11 -L/usr/lib -L../libs/opt -L/home/pgrosu/apps/protobuf/lib -I./gens -I/home/pgrosu/apps/protobuf/include -I../include -lgrpc++ -lprotobuf  client.cc gens/*.o -o client

Initially I got some undefined errors like this:

$ g++ -std=c++11 -L/usr/lib -L../libs/opt -L/home/pgrosu/apps/protobuf/lib -I./gens -I/home/pgrosu/apps/protobuf/include -I../include -lgrpc++ -lprotobuf  client.cc gens/*.o -o client
../libs/opt/libgrpc++.so: undefined reference to `SSL_CTX_free'
../libs/opt/libgrpc++.so: undefined reference to `X509_NAME_get_index_by_NID'
../libs/opt/libgrpc++.so: undefined reference to `EC_KEY_free'
../libs/opt/libgrpc++.so: undefined reference to `CRYPTO_set_locking_callback'
../libs/opt/libgrpc++.so: undefined reference to `SSL_CTX_get_cert_store'
../libs/opt/libgrpc++.so: undefined reference to `EVP_DigestVerifyInit'
...
$

I then referenced the boringssl library, and during the compilation I got the following error:

g++ -std=c++11 -L/usr/lib -L../libs/opt -L/home/pgrosu/apps/protobuf/lib -I./gens -I/home/pgrosu/apps/protobuf/include -I../include -lgrpc++ -lprotobuf -lboringssl client.cc gens/*.o -o client
/usr/bin/ld: skipping incompatible /usr/lib/libm.so when searching for -lm
/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/bin/ld: client: hidden symbol `SSL_CTX_free' in ../libs/opt/libboringssl.a(ssl_lib.o) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
$

Since the SSL_CTX_free symbol is hidden from the Dynamic Shared Object (DSO) - as a way to probably improve loading times - I then proceeded to do the following change to the grpc Makefile:

$ cp Makefile Makefile-orig
$ sed s/-fvisibility=hidden//g Makefile > Makefile-not-hidden
$ cp Makefile-not-hidden Makefile

I then recompiled grpc and rebuilt the googleapis, and the client now compiles without the need for referencing BoringSSL, like this:

$ g++ -std=c++11 -L/usr/lib -L../libs/opt -L/home/pgrosu/apps/protobuf/lib -I./gens -I/home/pgrosu/apps/protobuf/include -I../include -lgrpc++ -lprotobuf client.cc gens/*.o -o client

I'm not sure by how much the loading times would have been improved with having the visibility hidden for SSL, but it seems to run fairly fast even without it. Maybe this might not be the most efficient fix - and I will try to find a more elegant way - but it works for now.

I'm flexible and look forward to working together to explore possible solutions, for finding something that is best for all the users.

Hope it helps,
Paul

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions