libpthread.so.0: error adding symbols: DSO missing from command line

前端 未结 14 989
长情又很酷
长情又很酷 2020-11-22 07:00

When I\'m compiling openvswitch-1.5.0, I\'ve encountered the following compile error:

 gcc -Wstrict-prototypes -Wall -Wno-sign-compare -Wpointer-arith
     -         


        
相关标签:
14条回答
  • 2020-11-22 07:23

    If using g++, make sure that you are not running gcc instead

    0 讨论(0)
  • 2020-11-22 07:24

    You should mention the library on the command line after the object files being compiled:

     gcc -Wstrict-prototypes -Wall -Wno-sign-compare -Wpointer-arith -Wdeclaration-after-statement -Wformat-security -Wswitch-enum -Wunused-parameter -Wstrict-aliasing -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -Wno-override-init \
         -g -O2 -export-dynamic -o utilities/ovs-dpctl utilities/ovs-dpctl.o \
         lib/libopenvswitch.a \
         /home/jyyoo/src/dpdk/build/lib/librte_eal.a /home/jyyoo/src/dpdk/build/lib/libethdev.a /home/jyyoo/src/dpdk/build/lib/librte_cmdline.a /home/jyyoo/src/dpdk/build/lib/librte_hash.a /home/jyyoo/src/dpdk/build/lib/librte_lpm.a /home/jyyoo/src/dpdk/build/lib/librte_mbuf.a /home/jyyoo/src/dpdk/build/lib/librte_ring.a /home/jyyoo/src/dpdk/build/lib/librte_mempool.a /home/jyyoo/src/dpdk/build/lib/librte_malloc.a \
         -lrt -lm -lpthread 
    

    Explanation: the linking is dependent on the order of modules. Symbols are first requested, and then linked in from a library that has them. So you have to specify modules that use libraries first, and libraries after them. Like this:

    gcc x.o y.o z.o -la -lb -lc
    

    Moreover, in case there's a circular dependency, you should specify the same library on the command line several times. So in case libb needs symbol from libc and libc needs symbol from libb, the command line should be:

    gcc x.o y.o z.o -la -lb -lc -lb
    
    0 讨论(0)
提交回复
热议问题