From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by dpdk.org (Postfix) with ESMTP id 690AD1B53 for ; Mon, 5 Mar 2018 10:15:33 +0100 (CET) Received: by mail-lf0-f53.google.com with SMTP id m69so22023836lfe.8 for ; Mon, 05 Mar 2018 01:15:33 -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; bh=+KvGpVufve4LO9UBRdwzY1P45Zc+UR4sbD8XjfE6J/A=; b=q0OxRlnDp1dg0XNsFkX6B4o8/PD1WpBZ713ilGngQpIqfpEj8eRyUjicr8BWM6ZjZE y099LMUNca4kUKIbgPQuSKTMTsTDL69SjCUtH0lOaFAADj57d0fm424DlpINXIvKxIf+ URmFIG90l/xpmh673BDi8YUuegR3PhAG8k9x0Fs+JJqMzyVdqcCXRSOWvEIAyWtWm36u V2EANsW3VeTQGfngMRlSDVpNcHZagMJ2HWhNFjvgNRXfALjc3D8defYlgw1ZkMe9sz6B c8AoiTT+tMvqUfkvxymNgoDzdn5cwJz6hnwUBwbs+RTGNfsfTY5cz05YL46DUNrC0lWr S50w== 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; bh=+KvGpVufve4LO9UBRdwzY1P45Zc+UR4sbD8XjfE6J/A=; b=buJSV/WDEySjWv1WWiZSIR9y8kPrRZbcGlpA2obh5W8pMPg29hXtaJAzaEkjEa+5aS D5/Fwxif+casJCaJVMHlhqTd4PqkzXBtPw28R+bZN9Y8NsJB0CoXBPfNjbK5NpBH2Qka lzGC/KbsYuQPfWKfMpmkzRtajsy7/Y1BjoCa/6MQjBC+zfk4VaGVBmLQq485D7GYZ565 HE7mj9NtEGtJPhUK/ahUrc3TsT7DpcAjHf0l82VpXPUTixse+AueWUWr0og1m1xkl//q Qn/xTCh9gMQ89LT2NzBIQxV4ffh82DpSUNpSVFap38BLhq7ZPqCdCminzLJWiTt5qQza SK6w== X-Gm-Message-State: AElRT7EPaRTSTyjLHFhysJu9wjOsQakzregf1qVuYIYP1odKME0sX6Ol YXh32eibpBqHryRVCXmghPNs9Ah7Xivk5nsFLEo7TdFM X-Google-Smtp-Source: AG47ELvCvp99o6/CLPjuytUES6Tl59E7tgF5j1SFyN7AlnQiNYpE9XZPjLn+DTfM6KejKH5Bir6RWl58ZtofHlTU81U= X-Received: by 10.25.155.211 with SMTP id d202mr9554033lfe.125.1520241332688; Mon, 05 Mar 2018 01:15:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.46.0.196 with HTTP; Mon, 5 Mar 2018 01:15:31 -0800 (PST) In-Reply-To: References: From: Hui Liu Date: Mon, 5 Mar 2018 01:15:31 -0800 Message-ID: To: users@dpdk.org Content-Type: text/plain; charset="UTF-8" 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: Mon, 05 Mar 2018 09:15:33 -0000 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 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 --