You can, assuming that your .api file is named test.api:

1.) first you need to invoke vppapigen to generate JSON from your .api
file. For in-tree files, rules in src/suffix-rules.mk apply, so you can
mimick them by doing e.g.

gcc -E -P -C -x c test.api | ./build-root/tools/bin/vppapigen --input -
--json test.json

2.) now you need to generate vapi bindings based on the json:

src/vpp-api/vapi/vapi_c_gen.py test.json

This will then generate test.vapi.h, which you can #include in your
source code. The header file will also contain a macro named
DEFINE_VAPI_MSG_IDS_TEST_JSON
                    ^^^^
                     this is based on the name of the API

You need to specify this macro *once* in one of your source files (e.g.
the test.c you mention in your email)

Regards,
Klement

Quoting 重新开始 (2017-10-03 11:42:05)
>    Thank you! Klement.
>    Yes, I am not good at makeflie. After init study, i make success. But i
>    have a problem. I hope that you can answer me. If i write a plugin for vpp
>    and define some apis. The question si : could I call the apis through vapi
>    method?
>    ------------------ 原始邮件 ------------------
>    发件人: "Klement Sekera -X (ksekera - PA";<[email protected]>;
>    发送时间: 2017年10月3日(星期二) 下午5:01
>    收件人: "重新开始"<[email protected]>;"vpp-dev"<[email protected]>;
>    主题: Re: 回复: undefined reference to `vapi_register_msg'
>    I don't see them in the compile command
> 
>    >   cc -std=gnu99 -g -Wall -pthread -I/home/vpp/vpp/src
>    >      -Ihome//vpp/vpp/build-root/install-vpp-native/vpp/include
>    >      -I/home/test
>    >         test.c   -o test
> 
>    I strongly suggest you learn how gcc & make works...
> 
>    Quoting 重新开始 (2017-10-03 10:38:19)
>    >    Hi,
>    >    link libraries are same with test/ext/Makefile binaries. any other
>    >    libraries needed?
>    >    ------------------ 原始邮件 ------------------
>    >    发件人: "Klement Sekera -X (ksekera - PA";<[email protected]>;
>    >    发送时间: 2017年10月3日(星期二) 下午4:30
>    >    收件人: "重新开
>    始"<[email protected]>;"vpp-dev"<[email protected]>;
>    >    主题: Re: undefined reference to `vapi_register_msg'
>    >    Hi,
>    >
>    >    link against the same libraries as test/ext/Makefile binaries do:
>    >
>    >    -lvppinfra -lvlibmemoryclient -lsvm -lvapiclient
>    >
>    >    Regards,
>    >    Klement
>    >
>    >    Quoting 重新开始 (2017-10-03 10:17:24)
>    >    >    HI, i make the vapi test program, and make output the flowing
>    errors.
>    >    >    Maybe, any *.so should i add?
>    >    >    vpp@vpp-VirtualBox:~/test$ make
>    >    >    cc -std=gnu99 -g -Wall -pthread -I/home/vpp/vpp/src
>    >    >    -Ihome//vpp/vpp/build-root/install-vpp-native/vpp/include
>    >    -I/home/test
>    >    >    test.c   -o test
>    >    >    /tmp/ccq6LqEu.o: In function
>    `__vapi_constructor_delete_subif_reply':
>    >    >    /usr/include/vapi/vpe.api.vapi.h:6548: undefined reference to
>    >    >    `vapi_register_msg'
>    >    >    /tmp/ccq6LqEu.o: In function `__vapi_constructor_ip6_nd_event':
>    >    >    /usr/include/vapi/vpe.api.vapi.h:6570: undefined reference to
>    >    >    `vapi_register_msg'
>    >    >    /tmp/ccq6LqEu.o: In function
>    >    >    `__vapi_constructor_pg_create_interface_reply':
>    >    >    /usr/include/vapi/vpe.api.vapi.h:6592: undefined reference to
>    >    >    `vapi_register_msg'
>    >    >    /tmp/ccq6LqEu.o: In function
>    `__vapi_constructor_pg_capture_reply':
>    >    >    /usr/include/vapi/vpe.api.vapi.h:6614: undefined reference to
>    >    >    `vapi_register_msg'
>    >    >    /tmp/ccq6LqEu.o: In function
>    >    >    `__vapi_constructor_sw_interface_set_vpath_reply':
>    >    >    /usr/include/vapi/vpe.api.vapi.h:6636: undefined reference to
>    >    >    `vapi_register_msg'
>    >    >    /tmp/ccq6LqEu.o:/usr/include/vapi/vpe.api.vapi.h:6658: more
>    undefined
>    >    >    references to `vapi_register_msg' follow
>    >    >    /tmp/ccq6LqEu.o: In function `test_connect':
>    >    >    /home/vpp/test/test.c:46: undefined reference to
>    `vapi_ctx_alloc'
>    >    >    /home/vpp/test/test.c:48: undefined reference to `vapi_connect'
>    >    >    /home/vpp/test/test.c:51: undefined reference to
>    `vapi_disconnect'
>    >    >    /home/vpp/test/test.c:53: undefined reference to `vapi_ctx_free'
>    >    >    collect2: error: ld returned 1 exit status
>    >    >    <builtin>: recipe for target 'test' failed
>    >    >    make: *** [test] Error 1
_______________________________________________
vpp-dev mailing list
[email protected]
https://lists.fd.io/mailman/listinfo/vpp-dev
  • [vpp-dev] und... ????????
    • Re: [vpp... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)
      • [vpp... ????????
        • ... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)
          • ... ????????
            • ... Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco)

Reply via email to