Use Capn , Link with static libraries Failed ,But Link with dynamics libraries Success

217 views
Skip to first unread message

张小

unread,
Oct 11, 2019, 3:47:39 AM10/11/19
to Cap'n Proto
Hi,Kenton:
     I like capnp,  I use Capn ,Link with static libraries( use .a) Failed ,Error Like this

ERROR: xxxxx/BUILD:6:1: Linking of rule '//:test_capn' failed (Exit 1)
capnp/lib/libcapnpc.a(schema-parser.o):schema-parser.c++:function capnp::ParsedSchema::findNested(kj::StringPtr) const: error: undefined reference to 'capnp::SchemaLoader::get(unsigned long, capnp::schema::Brand::Reader, capnp::Schema) const'


but the libcapnpc.a has the “SchemaLoader::get” Symbol like this: 
nm capnp/lib/libcapnpc.a |grep SchemaLoader|grep get
                 nm -C lib/libcapnpc.a |grep SchemaLoader|grep get
                 U capnp::SchemaLoader::get(unsigned long, capnp::schema::Brand::Reader, capnp::Schema) const
                 U capnp::SchemaLoader::getType(capnp::schema::Type::Reader, capnp::Schema) const
                 U capnp::SchemaLoader::get(unsigned long, capnp::schema::Brand::Reader, capnp::Schema) const


 capnp/lib$ ll -rth
总用量 8.4M
-rw-r--r-- 1 mulou mulou 1.1M 9月  27 15:08 libcapnp.a
-rw-r--r-- 1 mulou mulou 1.4M 9月  27 15:08 libcapnpc.a
-rw-r--r-- 1 mulou mulou 330K 9月  27 15:08 libcapnp-json.a
-rw-r--r-- 1 mulou mulou 2.0M 9月  27 15:08 libcapnp-rpc.a
-rw-r--r-- 1 mulou mulou 941K 9月  27 15:08 libkj.a
-rw-r--r-- 1 mulou mulou 1.2M 9月  27 15:08 libkj-async.a
-rw-r--r-- 1 mulou mulou  70K 9月  27 15:08 libkj-test.a
-rw-r--r-- 1 mulou mulou 1.5M 9月  27 15:08 libkj-http.a

I try to link it with dynamic libraries,it works 

nm -C lib-old/libcapnpc.so |grep SchemaLoader|grep get
                 U capnp::SchemaLoader::get(unsigned long, capnp::schema::Brand::Reader, capnp::Schema) const
                 U capnp::SchemaLoader::getType(capnp::schema::Type::Reader, capnp::Schema) const

But I want to use static libraries instead of dynamic libraries because dynamic libraries are a little cumbersome to deploy. 

I  install the capn libraries  like this :

curl -O https://capnproto.org/capnproto-c++-0.7.0.tar.gz tar zxf capnproto-c++-0.7.0.tar.gz cd capnproto-c++-0.7.0 ./configure make -j6 check sudo make install

All the best
whutbd



张小

unread,
Oct 11, 2019, 7:12:26 AM10/11/19
to Cap'n Proto

nm -C libcapnpc.a |grep SchemaLoader|grep 'get('
                 U capnp::SchemaLoader::get(unsigned long, capnp::schema::Brand::Reader, capnp::Schema) const

nm -C libcapnp.a |grep SchemaLoader|grep 'get('
0000000000004250 T capnp::SchemaLoader::get(unsigned long, capnp::schema::Brand::Reader, capnp::Schema) const


it seems SchemaLoader::get Symbol in libcapnp.a , and in my bazel build file  like this 

cc_library(
    name = 'capnp',
    visibility = ["//visibility:public"],
    hdrs = glob([
        "include/capnp/*.h",
        "include/capnp/compat/*.h",
        "include/kj/*.h",
        "include/kj/**/*.h",
        ]),
    srcs = glob([
        "lib/libcapnpc.a",
        "lib/libcapnp.a",
        "lib/libkj.a",
        ]),

    strip_include_prefix = "include",
)








在 2019年10月11日星期五 UTC+8下午3:47:39,张小写道:

张小

unread,
Oct 11, 2019, 9:50:16 AM10/11/19
to Cap'n Proto
it seems libcapn.a and libcapnc.a conflict ?

在 2019年10月11日星期五 UTC+8下午7:12:26,张小写道:

张小

unread,
Oct 11, 2019, 10:30:43 AM10/11/19
to Cap'n Proto
Hi,Kenton:

  Is there a bazel  for capnp v0.7.0?
  thanks
  whutbd


在 2019年10月11日星期五 UTC+8下午3:47:39,张小写道:
Hi,Kenton:

张小

unread,
Oct 11, 2019, 11:48:18 AM10/11/19
to Cap'n Proto
bazel link *.a  in   Lexicographic order,how can I change it

bazel-out/k8-fastbuild/bin/_objs/test_capn/demo/test_capn_serialize_performance.pic.o
bazel-out/k8-fastbuild/bin/_objs/test_capn/demo/full_info.capnp.pic.o
capnp/lib/libcapnp.a
capnp/lib/libcapnpc.a
capnp/lib/libkj.a
-lstdc++
-lm



在 2019年10月11日星期五 UTC+8下午7:12:26,张小写道:

Kenton Varda

unread,
Oct 11, 2019, 1:00:26 PM10/11/19
to 张小, Cap'n Proto
Hi,

Sorry, I do not know how to control Bazel's linker command line order. Maybe it would help to define three separate cc_library rules for the three libraries, with the dependencies between them specified -- maybe Bazel will then recognize the dependency relationship and do the ordering correctly. But I don't know.

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/ae657a42-78cf-4903-8f76-00e186d9a256%40googlegroups.com.

张小

unread,
Oct 12, 2019, 11:18:18 PM10/12/19
to Cap'n Proto
hi Kenton:
   Thank you very much. I've settled it.Splitting bazel-dependent libraries into three libraries,It works

   best wish
   whutbd 

在 2019年10月12日星期六 UTC+8上午1:00:26,Kenton Varda写道:
To unsubscribe from this group and stop receiving emails from it, send an email to capn...@googlegroups.com.

张小

unread,
Oct 12, 2019, 11:20:35 PM10/12/19
to Cap'n Proto
 A friend who has the same problem can see it.
Reply all
Reply to author
Forward
0 new messages