From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by dpdk.org (Postfix) with ESMTP id 589F65F5F for ; Wed, 7 Mar 2018 02:02:17 +0100 (CET) Received: by mail-lf0-f49.google.com with SMTP id 70-v6so765559lfw.2 for ; Tue, 06 Mar 2018 17:02:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qMg/qpV/rWsCi/2Acr4Kdb2/njzZtDt2g4uftBfEJ6Q=; b=Qi2JcTIioCUU29FFMYqIzplukEbW1e5xf7kno1op2u/aHjDlV1imqrp7RUQl5itGl3 Lhfsrf1YwT9OgWwoQiJ796RGri3TvH8Fr0Pq0hcO7TrJ4XnuVc6ehfLRggLISxc28OJ5 0yi0GSX7UYK73LROVWI0fqR9phRhg7YkNKvOxVdJ4z2TwN4fAqFkHeC2WdklyjQc/rWY 0x+sARYd0Qr0lOGDHZDO7rrYyto2TE9j7WxtWmSNQgzzZBdEpS7DtzOp47JivreApDMw Ab+FPIuVc/nb6QsRAgznHUav7nFmDdAfrFPmvvngfhraO+IhQnC/6cXB3c5YfwFtkZJW 2nqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qMg/qpV/rWsCi/2Acr4Kdb2/njzZtDt2g4uftBfEJ6Q=; b=InBVuBmKXu1GFAwRlZ3GCVSR5az5D8phXmbv+/PAz/5863kPwpLvumWIx57m27H1yQ NXsayzSdOgcG94Ng4HFb8b3DP+68wbV2ptW71jJ/Dxz0aSP9+xxryN+nJXX2miU+t5tu 4rTZ6YpcRoiJOfciKZDvsv4avkQxellGUoihG4WUQKG2Sp/sgyTdUxodQ5Tlo/vK4Gvr 0Mf8qkk/uHHChBgyIPMglHmDlvl+riNNI4mw6jt7Yv6xvW3O0DDGVH5L4hQUikgK2GqG scD1HopG4oPpVyEYp1p4xEaEs9cXX/zuyIW/l//vRQ08iaioeV+g8Kyu74xLBDIurj51 YWRA== X-Gm-Message-State: AElRT7H6dC2n+oeF++84mm5MVGG3MvQg1s9bYLVnyhBSyV4xQ1QZlYrc 4kcJv7y9rvVfRGdG9CkX4WOx3kqTPoy3zFgPYRs= X-Google-Smtp-Source: AG47ELvSnW96tSuOUIfMFTvrA1yK+wByu7PDGs1Pp7dRqbNzaczX+cDXHDOoViuZRlIZpX8nxZ3VgiOZCW6jJd3JCbY= X-Received: by 10.46.81.25 with SMTP id f25mr13655642ljb.50.1520384536902; Tue, 06 Mar 2018 17:02:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.46.0.196 with HTTP; Tue, 6 Mar 2018 17:02:15 -0800 (PST) In-Reply-To: References: From: Hui Liu Date: Tue, 6 Mar 2018 17:02:15 -0800 Message-ID: To: "Wiles, Keith" Cc: "users@dpdk.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-users] DPDK library link issue with __attribute__((constructor)) X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Mar 2018 01:02:17 -0000 Hi Keith, Thanks a lot, that resolved my issue. The key is to use --whole-archive instead of --no-as-needed. --no-as-needed doesn't work. Thanks, Hui On Mon, Mar 5, 2018 at 5:28 AM, Wiles, Keith wrote: > > > > On Mar 5, 2018, at 3:15 AM, Hui Liu 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=3Dcore2 -mtune=3Dcore2 -msse3 -mfpmat= h=3Dsse > > --sysroot=3D/home/hliu/atomos/build-temp/build/tmp/work/ > core2-64-poky-linux/unittest/0.0-r0/recipe-sysroot > > -Wl,--hash-style=3Dgnu -Wl,--no-as-needed -o l2_ut_dpdk l2_ut_dpdk.c -W= all > > -Werror -g -lrte_mempool_stack -lrte_pmd_i40e -lrte_pmd_ark -lrte_ethde= v > > -lrte_pmd_null -lrte_pmd_null_crypto -lrte_lpm -lrte_pmd_ena -lrte_kvar= gs > > -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_distributo= r > > -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 =E2=80=94whole-archive =E2=80=A6 =E2=80= =94no-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 > =E2=80=94whole-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 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 > > --=20 Thanks & Best Regards Liu Hui --