From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 227D0199AE for ; Thu, 13 Sep 2018 17:22:16 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Sep 2018 08:22:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,369,1531810800"; d="scan'208";a="89731066" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga001.fm.intel.com with ESMTP; 13 Sep 2018 08:22:11 -0700 Received: from fmsmsx117.amr.corp.intel.com ([169.254.3.210]) by FMSMSX108.amr.corp.intel.com ([169.254.9.232]) with mapi id 14.03.0319.002; Thu, 13 Sep 2018 08:22:11 -0700 From: "Wiles, Keith" To: Amedeo Sapio CC: "users@dpdk.org" Thread-Topic: [dpdk-users] DPDK application as a library Thread-Index: AQHUSb1FJTldtEElDkelEteYE9yReqTrk22AgAANy4CAAyqugIAAAQwA Date: Thu, 13 Sep 2018 15:22:10 +0000 Message-ID: <0289C834-7154-478C-BE36-BBF20F4FD42C@intel.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.35.215] Content-Type: text/plain; charset="us-ascii" Content-ID: <0306ED32F069F749B53FA19F32074F6E@intel.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-users] DPDK application as a library X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Sep 2018 15:22:17 -0000 > On Sep 13, 2018, at 10:18 AM, Amedeo Sapio wr= ote: >=20 > The problem here was that DPDK libraries should be linked with the '--who= le-archive' option. All the credit goes to the guy that answered on stack o= verflow.=20 > I did not find this information in the documentation. Maybe it should be = added on this page. Not sure it is covered in other parts of the Doc, but here would be a thing= too. We do like patches to the docs and it would be great if you would think abo= ut sending one in to fix it. >=20 > --- > Amedeo >=20 >=20 > On Tue, Sep 11, 2018 at 5:56 PM Amedeo Sapio = wrote: > Thanks Keith for your answer.=20 > If I understand it correctly, you are suggesting to wrap the code that ne= eds DPDK in a library and then call the functions in this library from my c= ode. That is exactly what I did.=20 > I called rte_eal_init() before any other dpdk function. The dpdk code was= tested and worked when compiled as an APP, but the same code did not work = when used as library.=20 >=20 > The example with l2fwd is representative of what I am trying to do.=20 > I took the exact same code of the l2fwd example, then:=20 > - renamed the "main" function as "start" > - I added an header file with the signature of the "start" function=20 > - compiled as a libf2wd.a file.=20 > - created a new file with the new main function. This simply calls the "s= tart" function passing the argc,argv params.=20 > - compiled this new file with "gcc -l l2fwd -l dpdk -pthread -l dl -l n= uma ..." >=20 > When I run it I get: > EAL: Error - exiting with code: 1 > Cause: No Ethernet ports - bye >=20 > PS: I am sorry about the disclaimer, it is not under my control, it is in= serted automatically by my university mail system.=20 >=20 > Amedeo >=20 > On Tue, Sep 11, 2018 at 5:07 PM Wiles, Keith wrot= e: >=20 >=20 > > On Sep 11, 2018, at 5:49 AM, Amedeo Sapio w= rote: > >=20 > > Dear all, > > I am writing a program that uses dpdk. I wrote the program based on the > > dpdk examples, in particular using the Makefile provided in the example= s. > > If i compile the program as an APP (as describe here > > ), all goe= s > > well. >=20 > Sounds like you and this person need to get together here :-) > https://mails.dpdk.org/archives/users/2018-September/003439.html >=20 > > However, my code is part of a larger project, for which the use of a > > separate makefile causes a lot of troubles. > > So I compiled my code as a library, as described in the same page. > > Now, the program that calls the functions in the library (to initialize= the > > EAL) is getting this error: > >=20 >=20 > Did you call rte_eal_init() first as most of the routines depend on calli= ng this function before you call the other one. >=20 > As I explained the other thread, is that DPDK is not libc and you can not= just pick the functions you want to use for the most part. Some functions = are fairly independent, but not really as work is needed to make sure it ha= s all of the other inits called. >=20 > If you want to use DPDK today, the best method is to make sure you initia= lize DPDK correctly and then you can use parts of it for your needs. >=20 > As for the code that interacts with your application it is best to have a= directory with just the functions you need to build with DPDK and use thes= e functions as a bridge to/from your code. Using your header files and DPDK= header files in the same directory or file can cause a number of build pro= blems, which is why I use this type of method. Some routines in DPDK you ca= n call without any real problems, but sometimes it makes it easier to write= inline functions or functions that build most independent of DPDK and your= routines. Not sure explained it clearly, but I hope it helps. >=20 > BTW, please remove any disclaimers in your email as they do not apply to = a public email list. >=20 > > MBUF: error setting mempool handler > > Cannot init mbuf pool > >=20 > > I also made an experiment with the l2fwd example. The example compiled = as > > an app works correctly. But if I compile it as a library and then I cal= l > > the functions in this library from another program, I get: > >=20 > > EAL: Error - exiting with code: 1 > > Cause: No Ethernet ports - bye > >=20 > > I have one ethernet port using the igb_uio driver (seen from > > dpdk-devbind.py). When I compile my program, I link the following > > libraries: dpdk, pthread, dl, numa. DPDK is compiled from source as > > described here . > >=20 > > Thanks for your help, > >=20 > > --- > > Amedeo > >=20 > > --=20 > >=20 > > This message and its contents, including attachments are intended solel= y=20 > > for the original recipient. If you are not the intended recipient or ha= ve=20 > > received this message in error, please notify me immediately and delete= =20 > > this message from your computer system. Any unauthorized use or=20 > > distribution is prohibited. Please consider the environment before prin= ting=20 > > this email. >=20 > Regards, > Keith >=20 >=20 > --=20 >=20 > This message and its contents, including attachments are intended solely= =20 > for the original recipient. If you are not the intended recipient or have= =20 > received this message in error, please notify me immediately and delete=20 > this message from your computer system. Any unauthorized use or=20 > distribution is prohibited. Please consider the environment before printi= ng=20 > this email. >=20 > This message and its contents, including attachments are intended solely = for the original recipient. If you are not the intended recipient or have r= eceived this message in error, please notify me immediately and delete this= message from your computer system. Any unauthorized use or distribution is= prohibited. Please consider the environment before printing this email. Regards, Keith