> On Mar 5, 2018, at 3:15 AM, Hui Liu <onlyfl...@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 <onlyfl...@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 via email to