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

前端 未结 14 1398
长情又很酷
长情又很酷 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:14

    I found another case and therefore I thing you are all wrong.

    This is what I had:

    /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: eggtrayicon.o: undefined reference to symbol 'XFlush'
    /usr/lib64/libX11.so.6: error adding symbols: DSO missing from command line
    

    The problem is that the command line DID NOT contain -lX11 - although the libX11.so should be added as a dependency because there were also GTK and GNOME libraries in the arguments.

    So, the only explanation for me is that this message might have been intended to help you, but it didn't do it properly. This was probably simple: the library that provides the symbol was not added to the command line.

    Please note three important rules concerning linkage in POSIX:

    • Dynamic libraries have defined dependencies, so only libraries from the top-dependency should be supplied in whatever order (although after the static libraries)
    • Static libraries have just undefined symbols - it's up to you to know their dependencies and supply all of them in the command line
    • The order in static libraries is always: requester first, provider follows. Otherwise you'll get undefined symbol message, just like when you forgot to add the library to the command line
    • When you specify the library with -l, you never know whether it will take lib.so or lib.a. The dynamic library is preferred, if found, and static libraries only can be enforced by compiler option - that's all. And whether you have any problems as above, it depends on whether you had static or dynamic libraries
    • Well, sometimes the dependencies may be lacking in dynamic libraries :D

提交回复
热议问题