Search code examples
waf

Waf is unable to find 3rd party library


I have 2 libraries that exist at /usr/local/lib/libprotobuf.a and /usr/local/lib/libgrpc++.a. My waf script has

conf.check_cfg(package='protobuf', args='--cflags --libs', uselib_store="PROTOBUF")
conf.check_cfg(package='grpc++', args='--cflags --libs', uselib_store="GRPC")

when waf configure runs, it finds protobuf but says grpc++ isn't found.

Checking for 'protobuf' : yes
Checking for 'grpc++' : not found

How can it find 1 and not the other? How can I tell waf where to look for the grpc++ lib?


Solution

  • conf.check_cfg() use pkg-config files. You probably don't have a .pc file for libgrpc++ in /usr/local/lib/pkgconfig.

    In any case, you can define your flags manually (see wafbook §10.3.3):

    # arbitrary values :)
    conf.env.DEFINES_GRPC = ['HAVE_GRPC']
    conf.env.CFLAGS_GRPC = ['-O2']
    conf.env.LIB_GRPC = ['m']
    conf.env.LIBPATH_GRPC = ['/usr/lib']
    conf.env.LINKFLAGS_GRPC = ['-g']
    conf.env.INCLUDES_GRPC = ['/opt/lib']
    
    

    The first part a keyword known by waf (list in §10.3.3), the second part GRPC is the uselib_store name to use (with parameter use).