DPDK usage discussions
 help / color / mirror / Atom feed
From: 曾懷恩 <the@csie.io>
To: users@dpdk.org
Subject: [dpdk-users] how to add own header files when compiling
Date: Tue, 12 Mar 2019 11:57:16 +0800	[thread overview]
Message-ID: <C5170304-5449-4CD2-8B11-569C25055A5D@csie.io> (raw)

Hi, 

I am new to DPDK

I have two questions when I develop my project

first is i have a large project and wants to link my pre-compiled static libraries and my code to another code which call rte_ functions

 the source code tree looks like

--main.c
   foo.c
   foo.h
   dpdk_foo.c
   --com_util/xxx.c
     		   xxx.h
		   ooo.c
		   ooo.h
		   libcom_util.a

so i modify my makefile and dpdk example makefile to 

######################################
# Set variable
######################################
INCLUDE += -I. -I./com_util
CFLAGS += $(INCLUDE) -Wall -fPIC -g -std=c99 -D_XOPEN_SOURCE=700 -D_BSD_SOURCE

SUBDIRS := com_util dpdk

APP = pppoeclient

# all source are stored in SRCS-y
SRCS-y := pppd.c sock.c fsm.c codec.c dpdk_send.c

# Build using pkg-config variables if possible
$(shell pkg-config --exists libdpdk)

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
OBJ += $(SRC:.c=.o)
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
LDLIBS += -L./com_util -lcom_util

include $(RTE_SDK)/mk/rte.app.mk
##########################################

assume that libcom_util.a is pre-compiled

when i make, but it returns can’t find include header I defined in com_util directory

is there any solution that can include header files in dpdk foramt makefile?

and the second question is like above but only assuming libcom_util.a is not pre-compiled

how do I make makefile to compile sub-directory source code to library in dpdk format makefile

my original makefile without dpdk_foo.c is 

CC	= gcc -g
INCLUDE = -I. -I./com_util
CFLAGS = $(INCLUDE) -Wall -fPIC -g -std=c99 -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)

TARGET = pppoeclient
SRC = pppd.c sock.c fsm.c codec.c

OBJ = $(SRC:.c=.o) 

SUBDIRS := com_util

######################################
# Compile & Link
# 	Must use \tab key after new line
######################################
$(TARGET): $(OBJ) *.h
	for dir in $(SUBDIRS); \
	do make -C $$dir all || exit 1; \
	done
	$(CC) $(OBJ) $(CFLAGS) -L./com_util -o $(TARGET) \
	-static -lcom_util
######################################
# Clean 
######################################
clean:
	@for dir in $(SUBDIRS); do make -C $$dir clean|| exit 1; done
	rm -f *.o $(TARGET)

I have tried to just add rte_ library I need and --whole-archive tag to my original makefile

It can be compiled successfully but fail in execution time when call rte_pktmbuf_pool_create(); function (return “error setting mempool handler")

could anyone solve my questions please?

many thanks,

best regards,


                 reply	other threads:[~2019-03-14 21:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C5170304-5449-4CD2-8B11-569C25055A5D@csie.io \
    --to=the@csie.io \
    --cc=users@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).