You should remove -lvlib it is not needed here.
If you really want to link with vlib, you must fix the link ordering: vlib 
depends upon vppinfra (where os_exit is defined) so you'd need link as -lvlib 
-lvppinfra instead of the opposite (the C linker scan libraries symbols in 
reverse order, so symbols declared in a library are available to libraries 
listed *before*).

Best
ben

> -----Original Message-----
> From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 16:09
> To: Akash S R <akashsr.akas...@gmail.com>
> Cc: Benoit Ganne (bganne) <bga...@cisco.com>; Ole Troan
> <otr...@employees.org>; RaviKiran Veldanda <ravi.jup...@gmail.com>; vpp-
> dev <vpp-dev@lists.fd.io>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
> 
> Hi Akash,
> 
> Thansks, now after devtoolset,
> 
> 
> @Benoit Ganne (bganne) <mailto:bga...@cisco.com>  , @Ole Troan
> <mailto:otr...@employees.org>
> 
> i am getting following error
> 
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to
> `classify_get_trace_chain'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to
> `stat_segment_register_gauge'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to `os_exit'
> collect2: error: ld returned 1 exit status
> [root@8f57181df3a1 vpp_c_api_examples]#
> 
> Let me paste the code again,
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
> 
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
> 
> int main()
> {
>    char *name = "vpp-test-app";
> 
>    clib_mem_init_thread_safe (0, 64ULL << 20);
> 
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
> 
> Is this wrong way, i am trying to use APIs ?
> 
> Thanks,
> Regards
> Venu
> 
> 
> On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akas...@gmail.com
> <mailto:akashsr.akas...@gmail.com> > wrote:
> 
> 
>       Hey Venu,
> 
>       Try "scl enable devtoolset-9 bash" inside your docker or update your
> gcc version.
> 
> 
>       /Akash S R
> 
>       On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosy...@gmail.com
> <mailto:vjosy...@gmail.com> > wrote:
> 
> 
>               Hi Benoit,
> 
>               Thanks for quick reply.
> 
>               I have docker with following
>               [root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
>               vpp-lib-21.06.0-4~g0d9d3a0.x86_64
>               vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
>               vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
>               vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
>               vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
>               vpp-21.06.0-4~g0d9d3a0.x86_64
>               vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
>               vpp-devel-21.06.0-4~g0d9d3a0.x86_64
> 
>               This will vpp running in it.
> 
>               [root@8f57181df3a1 /]# cat /etc/redhat-release
>               CentOS Linux release 7.3.1611 (Core)
>               [root@8f57181df3a1 /]#
> 
>               > Eg. use devtoolset-9 (gcc-9).
> 
> 
>               How do I use it ?
> 
>               Thanks,
>               Regards,
>               Venu
> 
> 
>               On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne)
> <bga...@cisco.com <mailto:bga...@cisco.com> > wrote:
> 
> 
>                       You should upgrade your compiler... GCC-4 is way too
> old.
>                       Eg. use devtoolset-9 (gcc-9).
> 
>                       Best
>                       ben
> 
>                       > -----Original Message-----
>                       > From: vpp-dev@lists.fd.io <mailto:vpp-dev@lists.fd.io>
> <vpp-dev@lists.fd.io <mailto:vpp-dev@lists.fd.io> > On Behalf Of
> Venumadhav
>                       > Josyula
>                       > Sent: jeudi 30 septembre 2021 14:49
>                       > To: otr...@employees.org <mailto:otr...@employees.org>
>                       > Cc: RaviKiran Veldanda <ravi.jup...@gmail.com
> <mailto:ravi.jup...@gmail.com> >; vpp-dev <vpp-
>                       > d...@lists.fd.io <mailto:d...@lists.fd.io> >
>                       > Subject: Re: [vpp-dev] VPP Socket API how to use from
> the application
>                       > #socket-api #vpp #sock-api
>                       >
>                       > Hi Ole / Others,
>                       >
>                       >
>                       >
>                       > Thanks for your email, i getting following compilation
> error
>                       > [root@8f57181df3a1 vpp_c_api_examples]# gcc
> vpp_api_client_test3.c -o
>                       > vpp_api_client_test3.o -lvlibmemoryclient -lsvm -
> lvppinfra -lvlib
>                       > In file included from
> /usr/include/vppinfra/error.h:41:0,
>                       >                  from /usr/include/vlibapi/api.h:24,
>                       >                  from vpp_api_client_test3.c:3:
>                       > /usr/include/vppinfra/clib.h:43:18: error: missing
> binary operator before
>                       > token "("
>                       >  #if __has_include(<vppinfra/config.h>)
>                       >                   ^
>                       > In file included from
> /usr/include/vppinfra/mem.h:49:0,
>                       >                  from /usr/include/vppinfra/vec.h:42,
>                       >                  from
> /usr/include/vppinfra/error.h:53,
>                       >                  from /usr/include/vlibapi/api.h:24,
>                       >                  from vpp_api_client_test3.c:3:
>                       > /usr/include/vppinfra/string.h:92:34: error: expected
> ';', ',' or ')'
>                       > before 'dst'
>                       >  clib_memcpy_fast (void *restrict dst, const void
> *restrict src, size_t n)
>                       >                                   ^
>                       > [root@8f57181df3a1 vpp_c_api_examples]# vim
> /usr/include/vppinfra/clib.h
>                       > +43
>                       > [root@8f57181df3a1 vpp_c_api_examples]# vim
> /usr/include/vppinfra/clib.h
>                       > +43
>                       > [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
>                       > gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
>                       > Copyright (C) 2015 Free Software Foundation, Inc.
>                       > This is free software; see the source for copying
> conditions.  There is NO
>                       > warranty; not even for MERCHANTABILITY or FITNESS FOR
> A PARTICULAR
>                       > PURPOSE.
>                       >
>                       > [root@8f57181df3a1 vpp_c_api_examples]#
>                       >
>                       >
>                       > -----------------
>                       >
>                       > c -code
>                       > ----------------
>                       >
>                       >
>                       > #include<stdio.h>
>                       > #include<stdlib.h>
>                       > #include <vlibapi/api.h>
>                       > #include <vlibmemory/api.h>
>                       > #include <vpp/api/vpe_msg_enum.h>
>                       >
>                       > #define vl_typedefs
>                       > #define vl_endianfun
>                       > #include <vpp/api/vpe_all_api_h.h>
>                       > #undef vl_typedefs
>                       > #undef vl_endianfun
>                       >
>                       > int main()
>                       > {
>                       >    char *name = "vpp-test-app";
>                       >
>                       >    clib_mem_init_thread_safe (0, 64ULL << 20);
>                       >
>                       >    if (vl_client_api_map("/vpe-api"))
>                       >    {
>                       >         printf("unable to map....\n");
>                       >         goto quit;
>                       >    }
>                       >    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>                       >    {
>                       >         printf("unable to connect \n");
>                       >         vl_client_api_unmap();
>                       >         goto quit;
>                       >    }
>                       >    printf("successfully connected... \n");
>                       >  quit:
>                       >         return 0;
>                       > }
>                       >
>                       >
>                       > ------------
>                       >
>                       >
>                       > Can you please suggest what can i be doing worng ?
>                       >
>                       >
>                       > Thanks,
>                       > Regards,
>                       > Venu
>                       >
>                       >
>                       > On Thu, 30 Sept 2021 at 13:21, <otr...@employees.org
> <mailto:otr...@employees.org>
>                       > <mailto:otr...@employees.org
> <mailto:otr...@employees.org> > > wrote:
>                       >
>                       >
>                       >       Hi Venu,
>                       >
>                       >       > Any examples for VAPI shared to use binary
> APIs ?
>                       >
>                       >       Try this for a start:
>                       >       https://git.fd.io/vpp/tree/src/vpp-
> api/vapi/vapi_c_test.c
>                       >
>                       >       Cheers,
>                       >       Ole
>                       >
>                       >
> 
> 
> 
> 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#20249): https://lists.fd.io/g/vpp-dev/message/20249
Mute This Topic: https://lists.fd.io/mt/85796959/21656
Mute #vpp:https://lists.fd.io/g/vpp-dev/mutehashtag/vpp
Mute #socket-api:https://lists.fd.io/g/vpp-dev/mutehashtag/socket-api
Mute #sock-api:https://lists.fd.io/g/vpp-dev/mutehashtag/sock-api
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to