From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by dpdk.org (Postfix) with ESMTP id B7D14199AE for ; Thu, 13 Sep 2018 17:18:55 +0200 (CEST) Received: by mail-oi0-f41.google.com with SMTP id y207-v6so9730201oie.13 for ; Thu, 13 Sep 2018 08:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaust.edu.sa; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZwwKmV53la6KpIOiFz1FtWGO+QwDti/RXtGeTJuzlNk=; b=JlXeWxYHho7cyoj29DIughkzEqpqZWXH4eTS3U5wfBtHqwUB0EPGyJzxUswdZ63U4x WXB3lZB7sUUSo5X98veBJQ5pTDh1INm3UgjUoOrC2M4x6pUvYFY0pCqVGxSJV9KXiIDN MRR+2pTJ9hmv8EZR4T6QfKCHLWvoQrh96dnuM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZwwKmV53la6KpIOiFz1FtWGO+QwDti/RXtGeTJuzlNk=; b=jGZo7b6roie0omoNmxoDLBa4mlChp0iPuNclqR1fX1Ujx6lpUrOtoADTCRBqHFV9jD juZd9CwPOVYnyNgYzsn9SGTBDceJPO4F93tsvXSQORcgo/bd16CO8g/IEsFYgEQ2WnPX 8HNHHpEPGRnSEnVXkKVV76hJ+u87mutFoJt83aL08+IlTBDIrCPas4ruAC9ESprtgyj5 0p5MCKbjLGgfIDxJg8JLvkzmUTBL+v+lKZuN/1Qo3avYH8+9Amkzy2odd9NFBTN+P85+ 6AdrS5M+112yENlapazfe2fyV0UadHGgU4kIYBZTHQBAVBPgqF1HwJVF3FOCX1OQ3M3I QDIA== X-Gm-Message-State: APzg51DjUKPAcgUyR/iivUs2YU1c4avbMr++BO2H0Wym1im/NXeA24On 8FAdDuDDmDAjKl68WKyvC1NwBZxG3z8w8jDap6Rqd0zXbbn0oANbiIxKBL+YJ085X1CO5Y+on3h TFcoHqwP+ X-Google-Smtp-Source: ANB0VdYfR0y+ENidIckA40vd7p+GjqYAaIXU7AixA/eNEwSCqfBzPf0bedp2WYP5WmIyY4FgucuSIg== X-Received: by 2002:aca:c104:: with SMTP id r4-v6mr7055054oif.76.1536851934433; Thu, 13 Sep 2018 08:18:54 -0700 (PDT) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com. [209.85.210.45]) by smtp.gmail.com with ESMTPSA id 37-v6sm501646otj.38.2018.09.13.08.18.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Sep 2018 08:18:52 -0700 (PDT) Received: by mail-ot1-f45.google.com with SMTP id c12-v6so1588614otl.6 for ; Thu, 13 Sep 2018 08:18:52 -0700 (PDT) X-Received: by 2002:a9d:17d0:: with SMTP id j74-v6mr1638017otj.268.1536851931990; Thu, 13 Sep 2018 08:18:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amedeo Sapio Date: Thu, 13 Sep 2018 18:18:25 +0300 X-Gmail-Original-Message-ID: Message-ID: To: keith.wiles@intel.com Cc: users@dpdk.org X-KAUSTGmailUsers: PPSPAMCheckPass Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 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:18:56 -0000 The problem here was that DPDK libraries should be linked with the '--whole-archive' option. All the credit goes to the guy that answered on stack overflow . I did not find this information in the documentation. Maybe it should be added on this page . --- Amedeo On Tue, Sep 11, 2018 at 5:56 PM Amedeo Sapio wrote: > Thanks Keith for your answer. > If I understand it correctly, you are suggesting to wrap the code that > needs DPDK in a library and then call the functions in this library from my > code. That is exactly what I did. > 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. > > The example with l2fwd is representative of what I am trying to do. > I took the exact same code of the l2fwd example, then: > - renamed the "main" function as "start" > - I added an header file with the signature of the "start" function > - compiled as a libf2wd.a file. > - created a new file with the new main function. This simply calls the > "start" function passing the argc,argv params. > - compiled this new file with "gcc -l l2fwd -l dpdk -pthread -l dl -l > numa ..." > > When I run it I get: > EAL: Error - exiting with code: 1 > Cause: No Ethernet ports - bye > > PS: I am sorry about the disclaimer, it is not under my control, it is > inserted automatically by my university mail system. > > Amedeo > > On Tue, Sep 11, 2018 at 5:07 PM Wiles, Keith > wrote: > >> >> >> > On Sep 11, 2018, at 5:49 AM, Amedeo Sapio >> wrote: >> > >> > 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 >> examples. >> > If i compile the program as an APP (as describe here >> > ), all >> goes >> > well. >> >> Sounds like you and this person need to get together here :-) >> https://mails.dpdk.org/archives/users/2018-September/003439.html >> >> > 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: >> > >> >> Did you call rte_eal_init() first as most of the routines depend on >> calling this function before you call the other one. >> >> 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 >> has all of the other inits called. >> >> If you want to use DPDK today, the best method is to make sure you >> initialize DPDK correctly and then you can use parts of it for your needs. >> >> 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 these >> 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 >> problems, which is why I use this type of method. Some routines in DPDK you >> can 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. >> >> BTW, please remove any disclaimers in your email as they do not apply to >> a public email list. >> >> > MBUF: error setting mempool handler >> > Cannot init mbuf pool >> > >> > 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 call >> > the functions in this library from another program, I get: >> > >> > EAL: Error - exiting with code: 1 >> > Cause: No Ethernet ports - bye >> > >> > 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 . >> > >> > Thanks for your help, >> > >> > --- >> > Amedeo >> > >> > -- >> > >> > This message and its contents, including attachments are intended >> solely >> > for the original recipient. If you are not the intended recipient or >> have >> > received 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 >> >> >> -- >> >> This message and its contents, including attachments are intended solely >> for the original recipient. If you are not the intended recipient or have >> received 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. >> > -- This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received 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.