From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by dpdk.org (Postfix) with ESMTP id F02EFDE0 for ; Fri, 10 Jan 2014 21:17:59 +0100 (CET) Received: by mail-lb0-f175.google.com with SMTP id w6so3747832lbh.34 for ; Fri, 10 Jan 2014 12:19:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=FaJ/BqmdtCw3LW86GnjjRroQf0Ikm5qSe+yIlGasBzo=; b=PQk4A4+ZOcLJLO1SAsb0jgaJgQxO+mon1WnutG5Z3HGeI6fBRWEW+kIMwwLglZE5AT Jdbe4EHhfK/vSc85mE/x1eKmThPS8q42/srLbJ08OX4H90C06R25b0y1221ymAc2jgob 0hGgjHkcsTLGpOaRLuxvIqHk8Bumgtq5l5kqcmlEp9yT27eA/qj8ln6n+2O0tBPpPhxy PDL9CJyIXvB6h1FhjyzFVpz9dQUAYrJZZTx8s+AilNzyT8DpSMCeKaqisdRH8IxbGcFG +81IqKfDD6xtWHhS46LhWjvXQNGjM+AGh/3PZxBS0Sm6HOgrsAVizt0dIYqipnzpTBTX 9dqQ== X-Gm-Message-State: ALoCoQkR8Zc6P2mcJ2ZoZ8hhMD5yr77WM8tC2teWign8ATzyW/cZfb+YSs2JJ2rQWRb+5zvHyuTc MIME-Version: 1.0 X-Received: by 10.152.22.228 with SMTP id h4mr4605515laf.71.1389385150349; Fri, 10 Jan 2014 12:19:10 -0800 (PST) Received: by 10.112.137.34 with HTTP; Fri, 10 Jan 2014 12:19:10 -0800 (PST) In-Reply-To: References: Date: Fri, 10 Jan 2014 12:19:10 -0800 Message-ID: From: Dan Kan To: Hamid Ramazani Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] Useful: Simple C++ program & Makefile X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jan 2014 20:18:00 -0000 Hamid, I'm in the same situation as you in which I would like to write most of the application logic in C++. I was able to use CC=g++ by slightly modifying the makefiles in mk. I replaced all occurrences of "%.c" with "%.cc" using the following command. find . -name "*.mk" -exec sed -i 's/%\.c\([^[:alpha:]]\)/%\.cc\1/g' {} \; I also remove some warning flags as errors. Here are the diffs: diff -r mk/internal/rte.compile-pre.mk ../temp/dpdk-1.5.1r2/mk/internal/ rte.compile-pre.mk 39c39 < src2obj = $(strip $(patsubst %.cc,%.o,\ --- > src2obj = $(strip $(patsubst %.c,%.o,\ 48c48 < src2dep = $(strip $(call dotfile,$(patsubst %.cc,%.o.d, \ --- > src2dep = $(strip $(call dotfile,$(patsubst %.c,%.o.d, \ 53c53 < src2cmd = $(strip $(call dotfile,$(patsubst %.cc,%.o.cmd, \ --- > src2cmd = $(strip $(call dotfile,$(patsubst %.c,%.o.cmd, \ 125c125 < %.o: %.cc $$(wildcard $$(dep_$$@)) $$(DEP_$$(@)) FORCE --- > %.o: %.c $$(wildcard $$(dep_$$@)) $$(DEP_$$(@)) FORCE diff -r mk/rte.module.mk ../temp/dpdk-1.5.1r2/mk/rte.module.mk 36,37c36,37 < ifneq ($(MODULE),$(notdir $(SRCS-y:%.cc=%))) < $(MODULE)-objs += $(notdir $(SRCS-y:%.cc=%.o)) --- > ifneq ($(MODULE),$(notdir $(SRCS-y:%.c=%))) > $(MODULE)-objs += $(notdir $(SRCS-y:%.c=%.o)) diff -r mk/toolchain/gcc/rte.vars.mk ../temp/dpdk-1.5.1r2/mk/toolchain/gcc/ rte.vars.mk 71,73c71,73 < WERROR_FLAGS := -W -Wall -Werror < WERROR_FLAGS += -Wmissing-declarations -Wpointer-arith < WERROR_FLAGS += -Wcast-align -Wcast-qual --- > WERROR_FLAGS := -W -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes > WERROR_FLAGS += -Wmissing-declarations -Wold-style-definition -Wpointer-arith > WERROR_FLAGS += -Wcast-align -Wnested-externs -Wcast-qual Dan On Thu, Jan 9, 2014 at 10:30 PM, Hamid Ramazani wrote: > > I don't exactly know what is needed for C++. Please keep us informed. > > Hey Thomas, > > I've attached a simple program (main.cpp main.h and Makefile) that has > a C++ class and just prints some messages in the output. > Despite the fact that it's working fine, I'm sure the Makefile could > be written much better; Maybe I made it completer in future. > > All the Best, > --Hamid > > On 1/3/14, Thomas Monjalon wrote: > > Hello, > > > > 03/01/2014 11:48, Hamid Ramazani : > >> eal_timer.c:(.text+0x42c): undefined reference to `clock_gettime' > > > > From "man clock_gettime": > > Link with -lrt (only for glibc versions before 2.17). > > > >> g++ -m64 -pthread -march=native -DRTE_MACHINE_CPUFLAG_SSE > >> -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSSE3 > >> > -DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SS > >> SE3 -I/home/hamid/dpdk/dpdk-1.5.1r1/examples/sample/build/include > >> -I/home/hamid/dpdk/dpdk-1.5.1r1/x86_64-default-linuxapp-gcc/include > >> -include > >> > /home/hamid/dpdk/dpdk-1.5.1r1/x86_64-default-linuxapp-gcc/include/rte_conf > >> ig.h -O3 -W -Wall -Werror -Wmissing-declarations -Wpointer-arith > >> -Wcast-align -Wcast-qual -Wformat-nonliteral -Wformat-security -Wundef > >> -Wwrite-strings -Wl,-melf_x86_64 -Wl,-export-dynamic sample.cpp -o > >> sample -Wl,-L/home/hamid/dpdk/dpdk-1.5.1r1/examples/sample/build/lib > >> -Wl,-L/home/hamid/dpdk/dpdk-1.5.1r1/x86_64-default-linuxapp-gcc/lib > >> -Wl,-L/home/hamid/dpdk/dpdk-1.5.1r1/x86_64-default-linuxapp-gcc/lib > >> -Wl,-lrte_kni -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ixgbe -Wl,-lrte_mbuf > >> -Wl,-lrte_cmdline -Wl,-lrte_timer -Wl,-lrte_hash -Wl,-lrte_lpm > >> -Wl,--start-group -Wl,-lethdev -Wl,-lrte_malloc -Wl,-lrte_mempool > >> -Wl,-lrte_ring -Wl,-lrte_eal -Wl,-ldl -Wl,--end-group > > > > Try CONFIG_RTE_BUILD_COMBINE_LIBS=y and -lintel_dpdk instead of all these > > libraries. You can also remove the warning options if you want. > > > > You can also try to build your Makefile by including files like > > mk/rte.extapp.mk and defining CC=g++. > > I don't exactly know what is needed for C++. Please keep us informed. > > > > -- > > Thomas > > >