DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] building shared library
@ 2014-11-10 14:22 Newman Poborsky
  2014-11-11  1:01 ` Matthew Hall
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Newman Poborsky @ 2014-11-10 14:22 UTC (permalink / raw)
  To: dev

Hi,

is it possible to build a  dpdk app as a shared library?

I tried to put 'include $(RTE_SDK)/mk/rte.extshared.mk' in my Makefile (and
define SHARED) and it builds .so lib, but all rte_* symbols are undefined.

After that i tried adding:
LDLIBS += -lrte_eal -lrte_mbuf -lrte_cmdline -lrte_timer  -lrte_mempool
-lrte_ring  -lrte_pmd_ring -lethdev -lrte_malloc

And now almost all symbols in .so file are defined (missing only
rte_hexdump).

I thought this was gonna be it. But after using this library, pci probe-ing
fails since I don't have any pmd drivers registered, and
rte_eth_dev_count() returns 0.

But how are drivers supposed to be registered?

When I use gdb with regular dpdk app (not shared library), I can see this:
#0  0x000000000046fab0 in rte_eal_driver_register ()
#1  0x0000000000418fb7 in devinitfn_bond_drv ()
#2  0x00000000004f15ed in __libc_csu_init ()
#3  0x00007ffff6efee55 in __libc_start_main (main=0x41ee65 <main>, argc=1,
argv=0x7fffffffe4f8, init=0x4f15a0 <__libc_csu_init>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffe4e8) at
libc-start.c:246
#4  0x000000000041953c in _start ()


Ok, if I'm not mistaken, it seems driver registration is called before
main. How is this accomplished? Cause in shared library build, I don't have
this before main() and after rte_eal_init() (since driver list is empty)
everything else fails.

Any suggestions please? I'd really appreciate it...

BR,
Newman P.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-10 14:22 [dpdk-dev] building shared library Newman Poborsky
@ 2014-11-11  1:01 ` Matthew Hall
  2014-11-11  3:28 ` Chi, Xiaobo (NSN - CN/Hangzhou)
  2014-11-11 10:37 ` Gonzalez Monroy, Sergio
  2 siblings, 0 replies; 12+ messages in thread
From: Matthew Hall @ 2014-11-11  1:01 UTC (permalink / raw)
  To: Newman Poborsky; +Cc: dev

On Mon, Nov 10, 2014 at 03:22:40PM +0100, Newman Poborsky wrote:
> is it possible to build a  dpdk app as a shared library?

Yes it will work, with a bit of performance loss from the .so symbol lookup 
overhead. You have to set some of the build config options to get it to work 
though.

Matthew.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-10 14:22 [dpdk-dev] building shared library Newman Poborsky
  2014-11-11  1:01 ` Matthew Hall
@ 2014-11-11  3:28 ` Chi, Xiaobo (NSN - CN/Hangzhou)
  2014-11-11  7:29   ` Newman Poborsky
  2014-11-11 10:37 ` Gonzalez Monroy, Sergio
  2 siblings, 1 reply; 12+ messages in thread
From: Chi, Xiaobo (NSN - CN/Hangzhou) @ 2014-11-11  3:28 UTC (permalink / raw)
  To: ext Newman Poborsky, dev

Hi,
I am using DPDK based shared lib, but never met such problems. Can you please share this the result of "ldd xxxxx.so" and check if all those depended lib are all avalible? 

brgs,
chi xiaobo

-----Original Message-----
From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of ext Newman Poborsky
Sent: Monday, November 10, 2014 10:23 PM
To: dev@dpdk.org
Subject: [dpdk-dev] building shared library

Hi,

is it possible to build a  dpdk app as a shared library?

I tried to put 'include $(RTE_SDK)/mk/rte.extshared.mk' in my Makefile (and
define SHARED) and it builds .so lib, but all rte_* symbols are undefined.

After that i tried adding:
LDLIBS += -lrte_eal -lrte_mbuf -lrte_cmdline -lrte_timer  -lrte_mempool
-lrte_ring  -lrte_pmd_ring -lethdev -lrte_malloc

And now almost all symbols in .so file are defined (missing only
rte_hexdump).

I thought this was gonna be it. But after using this library, pci probe-ing
fails since I don't have any pmd drivers registered, and
rte_eth_dev_count() returns 0.

But how are drivers supposed to be registered?

When I use gdb with regular dpdk app (not shared library), I can see this:
#0  0x000000000046fab0 in rte_eal_driver_register ()
#1  0x0000000000418fb7 in devinitfn_bond_drv ()
#2  0x00000000004f15ed in __libc_csu_init ()
#3  0x00007ffff6efee55 in __libc_start_main (main=0x41ee65 <main>, argc=1,
argv=0x7fffffffe4f8, init=0x4f15a0 <__libc_csu_init>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffe4e8) at
libc-start.c:246
#4  0x000000000041953c in _start ()


Ok, if I'm not mistaken, it seems driver registration is called before
main. How is this accomplished? Cause in shared library build, I don't have
this before main() and after rte_eal_init() (since driver list is empty)
everything else fails.

Any suggestions please? I'd really appreciate it...

BR,
Newman P.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-11  3:28 ` Chi, Xiaobo (NSN - CN/Hangzhou)
@ 2014-11-11  7:29   ` Newman Poborsky
  0 siblings, 0 replies; 12+ messages in thread
From: Newman Poborsky @ 2014-11-11  7:29 UTC (permalink / raw)
  To: Chi, Xiaobo (NSN - CN/Hangzhou); +Cc: dev

Hi,

sure, here it is:
ldd libdpdk-api.so
        linux-vdso.so.1 =>  (0x00007fff3fffe000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f583dd99000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f583e5d4000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f583db7a000)

This is a library built with Makefile that has the following options:
RTE_BUILD_SHARED_LIB=y
CFLAGS += -fPIC
LDLIBS += -lrte_eal -lrte_mbuf -lrte_cmdline -lrte_timer  -lrte_mempool
-lrte_ring  -lrte_pmd_ring -lethdev -lrte_malloc
include $(RTE_SDK)/mk/rte.extshared.mk

There are no missing libraries.

I also had to add '-fPIC' flag to all Makefiles of lrte_*  libs above.   Is
this the correct way to build shared lib? Am I missing something?

When I build it as a regular dpdk app (like helloworld example) ldd output
is this:
ldd dpdk-api
        linux-vdso.so.1 =>  (0x00007fffacbfe000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ffe91b2b000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007ffe91922000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffe9171e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffe91139000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ffe92042000)
        libpcap.so.1 => /usr/local/lib/libpcap.so.1 (0x00007ffe90ef8000)

Thank you for any help!

BR,
Newman P.


On Tue, Nov 11, 2014 at 4:28 AM, Chi, Xiaobo (NSN - CN/Hangzhou) <
xiaobo.chi@nsn.com> wrote:

> Hi,
> I am using DPDK based shared lib, but never met such problems. Can you
> please share this the result of "ldd xxxxx.so" and check if all those
> depended lib are all avalible?
>
> brgs,
> chi xiaobo
>
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of ext Newman Poborsky
> Sent: Monday, November 10, 2014 10:23 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] building shared library
>
> Hi,
>
> is it possible to build a  dpdk app as a shared library?
>
> I tried to put 'include $(RTE_SDK)/mk/rte.extshared.mk' in my Makefile
> (and
> define SHARED) and it builds .so lib, but all rte_* symbols are undefined.
>
> After that i tried adding:
> LDLIBS += -lrte_eal -lrte_mbuf -lrte_cmdline -lrte_timer  -lrte_mempool
> -lrte_ring  -lrte_pmd_ring -lethdev -lrte_malloc
>
> And now almost all symbols in .so file are defined (missing only
> rte_hexdump).
>
> I thought this was gonna be it. But after using this library, pci probe-ing
> fails since I don't have any pmd drivers registered, and
> rte_eth_dev_count() returns 0.
>
> But how are drivers supposed to be registered?
>
> When I use gdb with regular dpdk app (not shared library), I can see this:
> #0  0x000000000046fab0 in rte_eal_driver_register ()
> #1  0x0000000000418fb7 in devinitfn_bond_drv ()
> #2  0x00000000004f15ed in __libc_csu_init ()
> #3  0x00007ffff6efee55 in __libc_start_main (main=0x41ee65 <main>, argc=1,
> argv=0x7fffffffe4f8, init=0x4f15a0 <__libc_csu_init>, fini=<optimized out>,
> rtld_fini=<optimized out>, stack_end=0x7fffffffe4e8) at
> libc-start.c:246
> #4  0x000000000041953c in _start ()
>
>
> Ok, if I'm not mistaken, it seems driver registration is called before
> main. How is this accomplished? Cause in shared library build, I don't have
> this before main() and after rte_eal_init() (since driver list is empty)
> everything else fails.
>
> Any suggestions please? I'd really appreciate it...
>
> BR,
> Newman P.
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-10 14:22 [dpdk-dev] building shared library Newman Poborsky
  2014-11-11  1:01 ` Matthew Hall
  2014-11-11  3:28 ` Chi, Xiaobo (NSN - CN/Hangzhou)
@ 2014-11-11 10:37 ` Gonzalez Monroy, Sergio
  2014-11-11 12:10   ` Newman Poborsky
  2 siblings, 1 reply; 12+ messages in thread
From: Gonzalez Monroy, Sergio @ 2014-11-11 10:37 UTC (permalink / raw)
  To: Newman Poborsky, dev

Hi  Newman,

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Newman Poborsky
> Sent: Monday, November 10, 2014 2:23 PM
> 
> Hi,
> 
> is it possible to build a  dpdk app as a shared library?
> 
> I tried to put 'include $(RTE_SDK)/mk/rte.extshared.mk' in my Makefile (and
> define SHARED) and it builds .so lib, but all rte_* symbols are undefined.
> 
Can you elaborate a bit on how you are building DPDK and your app?
Is your objective to build a single .so containing your app and all DPDK libs?
Or do you want your app to have a link dependency on DPDK shared libs?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-11 10:37 ` Gonzalez Monroy, Sergio
@ 2014-11-11 12:10   ` Newman Poborsky
  2014-11-11 14:18     ` Sergio Gonzalez Monroy
  0 siblings, 1 reply; 12+ messages in thread
From: Newman Poborsky @ 2014-11-11 12:10 UTC (permalink / raw)
  To: Gonzalez Monroy, Sergio; +Cc: dev

Hi,

I want to build one .so file with my app (it contains API that I want to
call through JNI) and all DPDK libs that I use in my app.

As I've already mentioned, when I build and start my dpdk app as a
standalone application, I can see that before main() is called, there is a
call to 'rte_eal_driver_register()' function for every driver. When I build
.so file, this does not happen and no driver is registered so everyting
after rte_eal_init() fails.


BR,
Newman

On Tue, Nov 11, 2014 at 11:37 AM, Gonzalez Monroy, Sergio <
sergio.gonzalez.monroy@intel.com> wrote:

> Hi  Newman,
>
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Newman Poborsky
> > Sent: Monday, November 10, 2014 2:23 PM
> >
> > Hi,
> >
> > is it possible to build a  dpdk app as a shared library?
> >
> > I tried to put 'include $(RTE_SDK)/mk/rte.extshared.mk' in my Makefile
> (and
> > define SHARED) and it builds .so lib, but all rte_* symbols are
> undefined.
> >
> Can you elaborate a bit on how you are building DPDK and your app?
> Is your objective to build a single .so containing your app and all DPDK
> libs?
> Or do you want your app to have a link dependency on DPDK shared libs?
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-11 12:10   ` Newman Poborsky
@ 2014-11-11 14:18     ` Sergio Gonzalez Monroy
  2014-11-11 14:44       ` Newman Poborsky
  0 siblings, 1 reply; 12+ messages in thread
From: Sergio Gonzalez Monroy @ 2014-11-11 14:18 UTC (permalink / raw)
  To: Newman Poborsky; +Cc: dev

On Tue, Nov 11, 2014 at 01:10:29PM +0100, Newman Poborsky wrote:
> Hi,
> 
> I want to build one .so file with my app (it contains API that I want to
> call through JNI) and all DPDK libs that I use in my app.
> 
> As I've already mentioned, when I build and start my dpdk app as a
> standalone application, I can see that before main() is called, there is a
> call to 'rte_eal_driver_register()' function for every driver. When I build
> .so file, this does not happen and no driver is registered so everyting
> after rte_eal_init() fails.
> 
Hi Newman,

AFAIK the current build system does not support that.

You can build DPDK as shared libs by setting the following config option:
CONFIG_RTE_BUILD_SHARED_LIB=y

Then build your app as an .so that links against DPDK libs, so you have 
explicit dependencies (such dependencies should show with ldd).

Is there any reason why you want everything to be a single .so ?

I don't know much about how Java loads DSOs but I reckon that it must resolve
explicit dependencies such as libc.

Thanks,
Sergio


> 
> BR,
> Newman
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-11 14:18     ` Sergio Gonzalez Monroy
@ 2014-11-11 14:44       ` Newman Poborsky
  2014-11-11 15:16         ` Newman Poborsky
  0 siblings, 1 reply; 12+ messages in thread
From: Newman Poborsky @ 2014-11-11 14:44 UTC (permalink / raw)
  To: Sergio Gonzalez Monroy; +Cc: dev

Hi Sergio,

no, that sounds good, thank you.  Since I'm not that familiar with DPDK
build system, where should this option be set? In 'lib' folder's Makefile?

Thank you once again!

BR,
Newman

On Tue, Nov 11, 2014 at 3:18 PM, Sergio Gonzalez Monroy <
sergio.gonzalez.monroy@intel.com> wrote:

> On Tue, Nov 11, 2014 at 01:10:29PM +0100, Newman Poborsky wrote:
> > Hi,
> >
> > I want to build one .so file with my app (it contains API that I want to
> > call through JNI) and all DPDK libs that I use in my app.
> >
> > As I've already mentioned, when I build and start my dpdk app as a
> > standalone application, I can see that before main() is called, there is
> a
> > call to 'rte_eal_driver_register()' function for every driver. When I
> build
> > .so file, this does not happen and no driver is registered so everyting
> > after rte_eal_init() fails.
> >
> Hi Newman,
>
> AFAIK the current build system does not support that.
>
> You can build DPDK as shared libs by setting the following config option:
> CONFIG_RTE_BUILD_SHARED_LIB=y
>
> Then build your app as an .so that links against DPDK libs, so you have
> explicit dependencies (such dependencies should show with ldd).
>
> Is there any reason why you want everything to be a single .so ?
>
> I don't know much about how Java loads DSOs but I reckon that it must
> resolve
> explicit dependencies such as libc.
>
> Thanks,
> Sergio
>
>
> >
> > BR,
> > Newman
> >
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-11 14:44       ` Newman Poborsky
@ 2014-11-11 15:16         ` Newman Poborsky
  2014-11-11 15:26           ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 12+ messages in thread
From: Newman Poborsky @ 2014-11-11 15:16 UTC (permalink / raw)
  To: Sergio Gonzalez Monroy; +Cc: dev

Hi,

after building DPDK libs as shared libraries and linking it, I'm back to my
first problem: rte_eal_driver_register() never gest called and my app
crashes since there are no drivers registered.  As previously mentioned, in
regular DPDK user app this functions is called for every driver before
main(). How?

BR,
Newman

On Tue, Nov 11, 2014 at 3:44 PM, Newman Poborsky <newman555p@gmail.com>
wrote:

> Hi Sergio,
>
> no, that sounds good, thank you.  Since I'm not that familiar with DPDK
> build system, where should this option be set? In 'lib' folder's Makefile?
>
> Thank you once again!
>
> BR,
> Newman
>
> On Tue, Nov 11, 2014 at 3:18 PM, Sergio Gonzalez Monroy <
> sergio.gonzalez.monroy@intel.com> wrote:
>
>> On Tue, Nov 11, 2014 at 01:10:29PM +0100, Newman Poborsky wrote:
>> > Hi,
>> >
>> > I want to build one .so file with my app (it contains API that I want to
>> > call through JNI) and all DPDK libs that I use in my app.
>> >
>> > As I've already mentioned, when I build and start my dpdk app as a
>> > standalone application, I can see that before main() is called, there
>> is a
>> > call to 'rte_eal_driver_register()' function for every driver. When I
>> build
>> > .so file, this does not happen and no driver is registered so everyting
>> > after rte_eal_init() fails.
>> >
>> Hi Newman,
>>
>> AFAIK the current build system does not support that.
>>
>> You can build DPDK as shared libs by setting the following config option:
>> CONFIG_RTE_BUILD_SHARED_LIB=y
>>
>> Then build your app as an .so that links against DPDK libs, so you have
>> explicit dependencies (such dependencies should show with ldd).
>>
>> Is there any reason why you want everything to be a single .so ?
>>
>> I don't know much about how Java loads DSOs but I reckon that it must
>> resolve
>> explicit dependencies such as libc.
>>
>> Thanks,
>> Sergio
>>
>>
>> >
>> > BR,
>> > Newman
>> >
>>
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-11 15:16         ` Newman Poborsky
@ 2014-11-11 15:26           ` De Lara Guarch, Pablo
  2014-11-11 15:54             ` Neil Horman
  0 siblings, 1 reply; 12+ messages in thread
From: De Lara Guarch, Pablo @ 2014-11-11 15:26 UTC (permalink / raw)
  To: Newman Poborsky, Gonzalez Monroy, Sergio; +Cc: dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Newman Poborsky
> Sent: Tuesday, November 11, 2014 3:17 PM
> To: Gonzalez Monroy, Sergio
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] building shared library
> 
> Hi,
> 
> after building DPDK libs as shared libraries and linking it, I'm back to my
> first problem: rte_eal_driver_register() never gest called and my app
> crashes since there are no drivers registered.  As previously mentioned, in
> regular DPDK user app this functions is called for every driver before
> main(). How?

If I am not wrong here, you have to use the -d option to specify the driver you want to use.

Btw, the option you were looking for can be found in config/common_linuxapp or config/common_bsdapp.

Pablo
> 
> BR,
> Newman
> 
> On Tue, Nov 11, 2014 at 3:44 PM, Newman Poborsky
> <newman555p@gmail.com>
> wrote:
> 
> > Hi Sergio,
> >
> > no, that sounds good, thank you.  Since I'm not that familiar with DPDK
> > build system, where should this option be set? In 'lib' folder's Makefile?
> >
> > Thank you once again!
> >
> > BR,
> > Newman
> >
> > On Tue, Nov 11, 2014 at 3:18 PM, Sergio Gonzalez Monroy <
> > sergio.gonzalez.monroy@intel.com> wrote:
> >
> >> On Tue, Nov 11, 2014 at 01:10:29PM +0100, Newman Poborsky wrote:
> >> > Hi,
> >> >
> >> > I want to build one .so file with my app (it contains API that I want to
> >> > call through JNI) and all DPDK libs that I use in my app.
> >> >
> >> > As I've already mentioned, when I build and start my dpdk app as a
> >> > standalone application, I can see that before main() is called, there
> >> is a
> >> > call to 'rte_eal_driver_register()' function for every driver. When I
> >> build
> >> > .so file, this does not happen and no driver is registered so everyting
> >> > after rte_eal_init() fails.
> >> >
> >> Hi Newman,
> >>
> >> AFAIK the current build system does not support that.
> >>
> >> You can build DPDK as shared libs by setting the following config option:
> >> CONFIG_RTE_BUILD_SHARED_LIB=y
> >>
> >> Then build your app as an .so that links against DPDK libs, so you have
> >> explicit dependencies (such dependencies should show with ldd).
> >>
> >> Is there any reason why you want everything to be a single .so ?
> >>
> >> I don't know much about how Java loads DSOs but I reckon that it must
> >> resolve
> >> explicit dependencies such as libc.
> >>
> >> Thanks,
> >> Sergio
> >>
> >>
> >> >
> >> > BR,
> >> > Newman
> >> >
> >>
> >
> >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-11 15:26           ` De Lara Guarch, Pablo
@ 2014-11-11 15:54             ` Neil Horman
  2014-11-11 16:24               ` Newman Poborsky
  0 siblings, 1 reply; 12+ messages in thread
From: Neil Horman @ 2014-11-11 15:54 UTC (permalink / raw)
  To: De Lara Guarch, Pablo; +Cc: dev

On Tue, Nov 11, 2014 at 03:26:04PM +0000, De Lara Guarch, Pablo wrote:
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Newman Poborsky
> > Sent: Tuesday, November 11, 2014 3:17 PM
> > To: Gonzalez Monroy, Sergio
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] building shared library
> > 
> > Hi,
> > 
> > after building DPDK libs as shared libraries and linking it, I'm back to my
> > first problem: rte_eal_driver_register() never gest called and my app
> > crashes since there are no drivers registered.  As previously mentioned, in
> > regular DPDK user app this functions is called for every driver before
> > main(). How?
> 
> If I am not wrong here, you have to use the -d option to specify the driver you want to use.
> 
> Btw, the option you were looking for can be found in config/common_linuxapp or config/common_bsdapp.
> 

Alternatively, when you link your application you can speify
-llibrte_pmd_<driver> and your applicaion should call all the constructors when
the dynamic loader hits your binaries DT_NEEDED table.  Thats how you can avoid
the command line specification.

Neil

> Pablo
> > 
> > BR,
> > Newman
> > 
> > On Tue, Nov 11, 2014 at 3:44 PM, Newman Poborsky
> > <newman555p@gmail.com>
> > wrote:
> > 
> > > Hi Sergio,
> > >
> > > no, that sounds good, thank you.  Since I'm not that familiar with DPDK
> > > build system, where should this option be set? In 'lib' folder's Makefile?
> > >
> > > Thank you once again!
> > >
> > > BR,
> > > Newman
> > >
> > > On Tue, Nov 11, 2014 at 3:18 PM, Sergio Gonzalez Monroy <
> > > sergio.gonzalez.monroy@intel.com> wrote:
> > >
> > >> On Tue, Nov 11, 2014 at 01:10:29PM +0100, Newman Poborsky wrote:
> > >> > Hi,
> > >> >
> > >> > I want to build one .so file with my app (it contains API that I want to
> > >> > call through JNI) and all DPDK libs that I use in my app.
> > >> >
> > >> > As I've already mentioned, when I build and start my dpdk app as a
> > >> > standalone application, I can see that before main() is called, there
> > >> is a
> > >> > call to 'rte_eal_driver_register()' function for every driver. When I
> > >> build
> > >> > .so file, this does not happen and no driver is registered so everyting
> > >> > after rte_eal_init() fails.
> > >> >
> > >> Hi Newman,
> > >>
> > >> AFAIK the current build system does not support that.
> > >>
> > >> You can build DPDK as shared libs by setting the following config option:
> > >> CONFIG_RTE_BUILD_SHARED_LIB=y
> > >>
> > >> Then build your app as an .so that links against DPDK libs, so you have
> > >> explicit dependencies (such dependencies should show with ldd).
> > >>
> > >> Is there any reason why you want everything to be a single .so ?
> > >>
> > >> I don't know much about how Java loads DSOs but I reckon that it must
> > >> resolve
> > >> explicit dependencies such as libc.
> > >>
> > >> Thanks,
> > >> Sergio
> > >>
> > >>
> > >> >
> > >> > BR,
> > >> > Newman
> > >> >
> > >>
> > >
> > >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] building shared library
  2014-11-11 15:54             ` Neil Horman
@ 2014-11-11 16:24               ` Newman Poborsky
  0 siblings, 0 replies; 12+ messages in thread
From: Newman Poborsky @ 2014-11-11 16:24 UTC (permalink / raw)
  To: Neil Horman; +Cc: dev

It works!!!  Thanks everybody!

I wasn't using '-Wl,--no-as-needed'  while compiling, so no PMD driver was
linked and hence no constructor called. After putting this options, it
finally works.

Again, thank you very much, I could never figure out all these steps on my
own!

BR,
Newman

On Tue, Nov 11, 2014 at 4:54 PM, Neil Horman <nhorman@tuxdriver.com> wrote:

> On Tue, Nov 11, 2014 at 03:26:04PM +0000, De Lara Guarch, Pablo wrote:
> >
> >
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Newman Poborsky
> > > Sent: Tuesday, November 11, 2014 3:17 PM
> > > To: Gonzalez Monroy, Sergio
> > > Cc: dev@dpdk.org
> > > Subject: Re: [dpdk-dev] building shared library
> > >
> > > Hi,
> > >
> > > after building DPDK libs as shared libraries and linking it, I'm back
> to my
> > > first problem: rte_eal_driver_register() never gest called and my app
> > > crashes since there are no drivers registered.  As previously
> mentioned, in
> > > regular DPDK user app this functions is called for every driver before
> > > main(). How?
> >
> > If I am not wrong here, you have to use the -d option to specify the
> driver you want to use.
> >
> > Btw, the option you were looking for can be found in
> config/common_linuxapp or config/common_bsdapp.
> >
>
> Alternatively, when you link your application you can speify
> -llibrte_pmd_<driver> and your applicaion should call all the constructors
> when
> the dynamic loader hits your binaries DT_NEEDED table.  Thats how you can
> avoid
> the command line specification.
>
> Neil
>
> > Pablo
> > >
> > > BR,
> > > Newman
> > >
> > > On Tue, Nov 11, 2014 at 3:44 PM, Newman Poborsky
> > > <newman555p@gmail.com>
> > > wrote:
> > >
> > > > Hi Sergio,
> > > >
> > > > no, that sounds good, thank you.  Since I'm not that familiar with
> DPDK
> > > > build system, where should this option be set? In 'lib' folder's
> Makefile?
> > > >
> > > > Thank you once again!
> > > >
> > > > BR,
> > > > Newman
> > > >
> > > > On Tue, Nov 11, 2014 at 3:18 PM, Sergio Gonzalez Monroy <
> > > > sergio.gonzalez.monroy@intel.com> wrote:
> > > >
> > > >> On Tue, Nov 11, 2014 at 01:10:29PM +0100, Newman Poborsky wrote:
> > > >> > Hi,
> > > >> >
> > > >> > I want to build one .so file with my app (it contains API that I
> want to
> > > >> > call through JNI) and all DPDK libs that I use in my app.
> > > >> >
> > > >> > As I've already mentioned, when I build and start my dpdk app as a
> > > >> > standalone application, I can see that before main() is called,
> there
> > > >> is a
> > > >> > call to 'rte_eal_driver_register()' function for every driver.
> When I
> > > >> build
> > > >> > .so file, this does not happen and no driver is registered so
> everyting
> > > >> > after rte_eal_init() fails.
> > > >> >
> > > >> Hi Newman,
> > > >>
> > > >> AFAIK the current build system does not support that.
> > > >>
> > > >> You can build DPDK as shared libs by setting the following config
> option:
> > > >> CONFIG_RTE_BUILD_SHARED_LIB=y
> > > >>
> > > >> Then build your app as an .so that links against DPDK libs, so you
> have
> > > >> explicit dependencies (such dependencies should show with ldd).
> > > >>
> > > >> Is there any reason why you want everything to be a single .so ?
> > > >>
> > > >> I don't know much about how Java loads DSOs but I reckon that it
> must
> > > >> resolve
> > > >> explicit dependencies such as libc.
> > > >>
> > > >> Thanks,
> > > >> Sergio
> > > >>
> > > >>
> > > >> >
> > > >> > BR,
> > > >> > Newman
> > > >> >
> > > >>
> > > >
> > > >
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-11-11 16:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-10 14:22 [dpdk-dev] building shared library Newman Poborsky
2014-11-11  1:01 ` Matthew Hall
2014-11-11  3:28 ` Chi, Xiaobo (NSN - CN/Hangzhou)
2014-11-11  7:29   ` Newman Poborsky
2014-11-11 10:37 ` Gonzalez Monroy, Sergio
2014-11-11 12:10   ` Newman Poborsky
2014-11-11 14:18     ` Sergio Gonzalez Monroy
2014-11-11 14:44       ` Newman Poborsky
2014-11-11 15:16         ` Newman Poborsky
2014-11-11 15:26           ` De Lara Guarch, Pablo
2014-11-11 15:54             ` Neil Horman
2014-11-11 16:24               ` Newman Poborsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).