DPDK usage discussions
 help / color / mirror / Atom feed
From: "Wiles, Keith" <keith.wiles@intel.com>
To: Hui Liu <onlyflyer@gmail.com>
Cc: "users@dpdk.org" <users@dpdk.org>
Subject: Re: [dpdk-users] DPDK library link issue with	__attribute__((constructor))
Date: Mon, 5 Mar 2018 13:28:42 +0000	[thread overview]
Message-ID: <CB89733A-C08B-4B5E-89B7-6AD9DDAF8B91@intel.com> (raw)
In-Reply-To: <CAF=f7336oictvTV3uD9hNpoDbchycLOchJu6Gyn=1MyDBEr24Q@mail.gmail.com>



> On Mar 5, 2018, at 3:15 AM, Hui Liu <onlyflyer@gmail.com> wrote:
> 
> I tried to put all the library into the command, but it still doesn't work.
> That's wired...
> 
> x86_64-poky-linux-gcc -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse
> --sysroot=/home/hliu/atomos/build-temp/build/tmp/work/core2-64-poky-linux/unittest/0.0-r0/recipe-sysroot
> -Wl,--hash-style=gnu -Wl,--no-as-needed -o l2_ut_dpdk l2_ut_dpdk.c -Wall
> -Werror -g -lrte_mempool_stack -lrte_pmd_i40e -lrte_pmd_ark -lrte_ethdev
> -lrte_pmd_null -lrte_pmd_null_crypto -lrte_lpm -lrte_pmd_ena -lrte_kvargs
> -lrte_cmdline -lrte_pmd_tap -lrte_pmd_sw_event -lrte_latencystats
> -lrte_bitratestats -lrte_efd -lrte_sched -lrte_pmd_kni -lrte_pmd_qede
> -lrte_hash -lrte_pmd_enic -lrte_pdump -lrte_pmd_lio -lrte_acl
> -lrte_pmd_af_packet -lrte_eventdev -lrte_port -lrte_ip_frag -lrte_pmd_bond
> -lrte_pmd_sfc_efx -lrte_pmd_e1000 -lrte_mbuf -lrte_pmd_virtio -lrte_metrics
> -lrte_cryptodev -lrte_reorder -lrte_pmd_ring -lrte_eal -lrte_distributor
> -lrte_vhost -lrte_pmd_bnxt -lrte_timer -lrte_pmd_avp
> -lrte_pmd_crypto_scheduler -lrte_pmd_thunderx_nicvf
> -lrte_pmd_skeleton_event -lrte_pmd_nfp -lrte_jobstats -lrte_net
> -lrte_mempool -lrte_pmd_ixgbe -lrte_mempool_ring -lrte_pipeline
> -lrte_pmd_octeontx_ssovf -lrte_pmd_vhost -lrte_meter -lrte_pmd_cxgbe
> -lrte_kni -lrte_pmd_vmxnet3_uio -lrte_ring -lrte_pmd_fm10k -lrte_table
> -lrte_cfgfile -lpthread -ldl

One way with the above is to use —whole-archive … —no-whole-archive around the archives you want to force include. The other way to is include the .o files as part of the link line instead of the .a file. The problem with —whole-archive is it pulls in the complete archive and increases footprint. Using the .o method is normally used here and they include these .o files in the application Makefile.

> 

> On Sun, Mar 4, 2018 at 9:08 PM, Hui Liu <onlyflyer@gmail.com> wrote:
> 
>> Hi Guys,
>> 
>> I am using DPDK with the yocto build system.
>> 
>> I found some static library is not linked because of the linker's
>> as-needed decision.
>> 
>> Some .a file use __attribute__((constructor)) to register their APIs,
>> we only know if we use these APIs at runtime, but linker make the decision
>> early and then discarded them.
>> 
>> I tried a lot to link the library I need:
>> 
>> 1, use -Wl, --no-as-needed, for example:
>> gcc a.c *-Wl, --no-as-needed* -ldl -ldpdk
>> 
>> 2, Put the library explicitly to the linker like this:
>> gcc a.c -Wl, --no-as-needed -ldl -ldpdk *-lrte_mempool*
>> 
>> At last, I still didn't find my library in the elf file.
>> 
>> Is there anything else I can try to link these library?
>> 
>> --
>> Thanks & Best Regards
>> Liu Hui
>> --
>> 
> 
> 
> 
> -- 
> Thanks & Best Regards
> Liu Hui
> --

Regards,
Keith


  reply	other threads:[~2018-03-05 13:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05  5:08 Hui Liu
2018-03-05  9:15 ` Hui Liu
2018-03-05 13:28   ` Wiles, Keith [this message]
2018-03-07  1:02     ` Hui Liu

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=CB89733A-C08B-4B5E-89B7-6AD9DDAF8B91@intel.com \
    --to=keith.wiles@intel.com \
    --cc=onlyflyer@gmail.com \
    --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).