* [dpdk-users] Building a shared library that uses DPDK
@ 2018-02-15 0:06 Jeffrey Helt
2018-02-15 1:08 ` Stephen Hemminger
0 siblings, 1 reply; 4+ messages in thread
From: Jeffrey Helt @ 2018-02-15 0:06 UTC (permalink / raw)
To: users
Hi,
I am attempting to build a shared library that uses DPDK, specifically that wraps the Linux socket API and backs it by shared memory DPDK shared memory regions. I built DPDK 17.11 with “CONFIG_RTE_BUILD_SHARED_LIB=y”. In my shared library directory, I am using the following Makefile:
ifeq ($(RTE_SDK),)
$(error "Please define RTE_SDK environment variable")
endif
# Default target, can be overridden by command line or environment
RTE_TARGET ?= x86_64-native-linuxapp-gcc
include $(RTE_SDK)/mk/rte.vars.mk
# binary name
SHARED = libshim.so
# all source are stored in SRCS-y
SRCS-y := wrap_socket.c
CFLAGS += -O3
include $(RTE_SDK)/mk/rte.extshared.mk
However, whenever I try to use my library, such as with "LD_PRELOAD=./build/lib/libshim.so ./test”, I receive "symbol lookup error: ./build/lib/libshim.so: undefined symbol: rte_eal_init”. What am I missing?
Thank you in advance for help!
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-users] Building a shared library that uses DPDK
2018-02-15 0:06 [dpdk-users] Building a shared library that uses DPDK Jeffrey Helt
@ 2018-02-15 1:08 ` Stephen Hemminger
2018-02-15 2:34 ` Jeffrey Helt
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2018-02-15 1:08 UTC (permalink / raw)
To: Jeffrey Helt; +Cc: users
On Wed, 14 Feb 2018 19:06:03 -0500
Jeffrey Helt <jhelt@andrew.cmu.edu> wrote:
> Hi,
>
> I am attempting to build a shared library that uses DPDK, specifically that wraps the Linux socket API and backs it by shared memory DPDK shared memory regions. I built DPDK 17.11 with “CONFIG_RTE_BUILD_SHARED_LIB=y”. In my shared library directory, I am using the following Makefile:
>
> ifeq ($(RTE_SDK),)
> $(error "Please define RTE_SDK environment variable")
> endif
>
> # Default target, can be overridden by command line or environment
> RTE_TARGET ?= x86_64-native-linuxapp-gcc
>
> include $(RTE_SDK)/mk/rte.vars.mk
>
> # binary name
> SHARED = libshim.so
>
> # all source are stored in SRCS-y
> SRCS-y := wrap_socket.c
>
> CFLAGS += -O3
>
> include $(RTE_SDK)/mk/rte.extshared.mk
>
> However, whenever I try to use my library, such as with "LD_PRELOAD=./build/lib/libshim.so ./test”, I receive "symbol lookup error: ./build/lib/libshim.so: undefined symbol: rte_eal_init”. What am I missing?
>
> Thank you in advance for help!
>
> Jeff
The DPDK builds lots of little shared libraries.
You need to have all of them in your LD_LIBRARY_PATH and then add your socket wrapper.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-users] Building a shared library that uses DPDK
2018-02-15 1:08 ` Stephen Hemminger
@ 2018-02-15 2:34 ` Jeffrey Helt
2018-02-15 23:44 ` Jeffrey Helt
0 siblings, 1 reply; 4+ messages in thread
From: Jeffrey Helt @ 2018-02-15 2:34 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: users
> On Feb 14, 2018, at 8:08 PM, Stephen Hemminger <stephen@networkplumber.org> wrote:
>
> On Wed, 14 Feb 2018 19:06:03 -0500
> Jeffrey Helt <jhelt@andrew.cmu.edu> wrote:
>
>> Hi,
>>
>> I am attempting to build a shared library that uses DPDK, specifically that wraps the Linux socket API and backs it by shared memory DPDK shared memory regions. I built DPDK 17.11 with “CONFIG_RTE_BUILD_SHARED_LIB=y”. In my shared library directory, I am using the following Makefile:
>>
>> ifeq ($(RTE_SDK),)
>> $(error "Please define RTE_SDK environment variable")
>> endif
>>
>> # Default target, can be overridden by command line or environment
>> RTE_TARGET ?= x86_64-native-linuxapp-gcc
>>
>> include $(RTE_SDK)/mk/rte.vars.mk
>>
>> # binary name
>> SHARED = libshim.so
>>
>> # all source are stored in SRCS-y
>> SRCS-y := wrap_socket.c
>>
>> CFLAGS += -O3
>>
>> include $(RTE_SDK)/mk/rte.extshared.mk
>>
>> However, whenever I try to use my library, such as with "LD_PRELOAD=./build/lib/libshim.so ./test”, I receive "symbol lookup error: ./build/lib/libshim.so: undefined symbol: rte_eal_init”. What am I missing?
>>
>> Thank you in advance for help!
>>
>> Jeff
> The DPDK builds lots of little shared libraries.
> You need to have all of them in your LD_LIBRARY_PATH and then add your socket wrapper.
Using `export LD_LIBRARY_PATH="/users/jhelt/dpdk/x86_64-native-linuxapp-gcc/lib/librte_eal.so”` before building and/or running doesn’t seem to change anything. Using ldd, I noticed that no dpdk shared objects are required by my library (see below), which seems like a more fundamental issue to me, although admittedly I am not that experienced in debugging linking issues.
$ ldd ./build/lib/libshim.so
linux-vdso.so.1 => (0x00007fff907e2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe76b06a000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe76b636000)
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-users] Building a shared library that uses DPDK
2018-02-15 2:34 ` Jeffrey Helt
@ 2018-02-15 23:44 ` Jeffrey Helt
0 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Helt @ 2018-02-15 23:44 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: users
> On Feb 14, 2018, at 9:34 PM, Jeffrey Helt <jhelt@andrew.cmu.edu> wrote:
>
>
>> On Feb 14, 2018, at 8:08 PM, Stephen Hemminger <stephen@networkplumber.org> wrote:
>>
>> On Wed, 14 Feb 2018 19:06:03 -0500
>> Jeffrey Helt <jhelt@andrew.cmu.edu> wrote:
>>
>>> Hi,
>>>
>>> I am attempting to build a shared library that uses DPDK, specifically that wraps the Linux socket API and backs it by shared memory DPDK shared memory regions. I built DPDK 17.11 with “CONFIG_RTE_BUILD_SHARED_LIB=y”. In my shared library directory, I am using the following Makefile:
>>>
>>> ifeq ($(RTE_SDK),)
>>> $(error "Please define RTE_SDK environment variable")
>>> endif
>>>
>>> # Default target, can be overridden by command line or environment
>>> RTE_TARGET ?= x86_64-native-linuxapp-gcc
>>>
>>> include $(RTE_SDK)/mk/rte.vars.mk
>>>
>>> # binary name
>>> SHARED = libshim.so
>>>
>>> # all source are stored in SRCS-y
>>> SRCS-y := wrap_socket.c
>>>
>>> CFLAGS += -O3
>>>
>>> include $(RTE_SDK)/mk/rte.extshared.mk
>>>
>>> However, whenever I try to use my library, such as with "LD_PRELOAD=./build/lib/libshim.so ./test”, I receive "symbol lookup error: ./build/lib/libshim.so: undefined symbol: rte_eal_init”. What am I missing?
>>>
>>> Thank you in advance for help!
>>>
>>> Jeff
>> The DPDK builds lots of little shared libraries.
>> You need to have all of them in your LD_LIBRARY_PATH and then add your socket wrapper.
>
> Using `export LD_LIBRARY_PATH="/users/jhelt/dpdk/x86_64-native-linuxapp-gcc/lib/librte_eal.so”` before building and/or running doesn’t seem to change anything. Using ldd, I noticed that no dpdk shared objects are required by my library (see below), which seems like a more fundamental issue to me, although admittedly I am not that experienced in debugging linking issues.
>
> $ ldd ./build/lib/libshim.so
> linux-vdso.so.1 => (0x00007fff907e2000)
> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe76b06a000)
> /lib64/ld-linux-x86-64.so.2 (0x00007fe76b636000)
>
> Jeff
I managed to solve this issue. For future reference for anyone facing a similar issue, I needed to update the Makefile to the following. Note the LDLIBS. The "LDFLAGS += --no-undefined” was helpful in debugging missing symbols but is not required. After this change, I still needed to add the DPDK lib directory to my LD_LIBRARY_PATH as Stephen suggested.
Jeff
include $(RTE_SDK)/mk/rte.vars.mk
# binary name
SHARED = libshim.so
# all source are stored in SRCS-y
SRCS-y := wrap_socket.c
CFLAGS += -O3
LDFLAGS += --no-undefined
LDLIBS += -ldl -l:librte_eal.so
include $(RTE_SDK)/mk/rte.extshared.mk
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-15 23:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 0:06 [dpdk-users] Building a shared library that uses DPDK Jeffrey Helt
2018-02-15 1:08 ` Stephen Hemminger
2018-02-15 2:34 ` Jeffrey Helt
2018-02-15 23:44 ` Jeffrey Helt
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).