libpthread.so.0 : 기호 추가 오류 : 명령 줄에 DSO가 없습니다.
openvswitch-1.5.0을 컴파일 할 때 다음 컴파일 오류가 발생했습니다.
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 ***-lpthread*** -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
/usr/bin/ld: /home/jyyoo/src/dpdk/build/lib/librte_eal.a(eal.o): undefined reference
to symbol 'pthread_create@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from
command line
의 기호를 보려고하면 libpthread
괜찮아 보입니다.
$ readelf -s /lib/x86_64-linux-gnu/libpthread.so.0 | grep pthread_create
199: 0000000000008220 2814 FUNC GLOBAL DEFAULT 13 pthread_create@@GLIBC_2.2.5
173: 0000000000008220 2814 FUNC LOCAL DEFAULT 13 __pthread_create_2_1
462: 0000000000008220 2814 FUNC GLOBAL DEFAULT 13 pthread_create@@GLIBC_2.2
힌트 나 조언을 줄 수 있습니까?
오브젝트 파일이 컴파일 된 후 명령 행에서 라이브러리를 언급해야합니다 .
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
설명 : 연결은 모듈 순서에 따라 다릅니다. 먼저 심볼을 요청한 다음 심볼이있는 라이브러리에서 연결합니다. 따라서 라이브러리를 먼저 사용하고 그 뒤에 라이브러리를 사용하는 모듈을 지정해야합니다. 이처럼 :
gcc x.o y.o z.o -la -lb -lc
또한 순환 종속성이있는 경우 명령 행에서 동일한 라이브러리를 여러 번 지정해야합니다. 그래서 경우 libb
에서 기호를 필요로 libc
하고 libc
에서 기호 필요 libb
, 명령 줄이되어야한다 :
gcc x.o y.o z.o -la -lb -lc -lb
오류 메시지는 배포 / 컴파일러 버전에 따라 다릅니다.
우분투 소스 :
/usr/bin/ld: /mnt/root/ffmpeg-2.1.1//libavformat/libavformat.a(http.o): undefined reference to symbol 'inflateInit2_'
/lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
우분투 Raring : (보다 유익한)
/usr/bin/ld: note: 'uncompress' is defined in DSO /lib/x86_64-linux-gnu/libz.so.1 so try adding it to the linker command line
솔루션 : 연결 단계에서 컴파일 단계에서 라이브러리가 누락되었을 수 있습니다. 필자의 경우 makefile / GCC 플래그에 '-lz'를 추가했습니다.
배경 : DSO는 동적 공유 객체 또는 공유 라이브러리입니다.
나는 또 다른 사건을 발견했기 때문에 당신이 모두 틀린 것입니다.
이것이 내가 가진 것입니다 :
/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
문제는 명령 행에 DID가 포함되어 -lX11
있지 않다는 것입니다. 비록 libX11.so는 인수에 GTK와 GNOME 라이브러리도 있기 때문에 의존성으로 추가되어야합니다.
따라서 저에게 유일한 설명은이 메시지가 귀하 를 돕기 위한 것일 수도 있지만 제대로 수행되지 않았다는 것입니다. 이것은 아마도 간단했을 것입니다. 심볼을 제공하는 라이브러리는 명령 행에 추가되지 않았습니다.
POSIX의 연계에 관한 세 가지 중요한 규칙에 유의하십시오.
- 동적 라이브러리는 종속성을 정의 했으므로 최상위 라이브러리의 라이브러리 만 (정적 라이브러리 이후에도) 순서에 상관없이 제공해야합니다.
- 정적 라이브러리에는 정의되지 않은 기호가 있습니다. 종속성을 파악하고 명령 줄에 모든 것을 제공하는 것은 사용자의 책임입니다.
- 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<name>
, you never know whether it will takelib<name>.so
orlib<name>.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
I found I had the same error. I was compiling a code with both lapack and blas. When I switched the order that the two libraries were called the error went away.
"LAPACK_LIB = -llapack -lblas" worked where "LAPACK_LIB = -lblas -llapack" gave the error described above.
I also encountered same problem. I do not know why, i just add -lpthread
option to compiler and everything ok.
Old:
$ g++ -rdynamic -m64 -fPIE -pie -o /tmp/node/out/Release/mksnapshot ...*.o *.a -ldl -lrt
got following error. If i append -lpthread
option to above command then OK.
/usr/bin/ld: /tmp/node/out/Release/obj.host/v8_libbase/deps/v8/src/base/platform/condition-variable.o: undefined reference to symbol 'pthread_condattr_setclock@@GLIBC_2.3.3'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
What I have found is that sometimes the library that the linker complains about is not the one causing the problem. Possibly there is a clever way to work out where the problem is but this is what I do:
- Comment out all the linked libraries in the link command.
- Clean out all .o's, .so's etc (Usually make clean is enough, but you may want to run a recursive find + rm, or something similar).
- Uncomment the libraries in the link command one at a time and re-arrange the order as necessary.
@peter karasev: I have come across the same problem with a gcc 4.8.2 cmake project on CentOS7. The order of the libraries in "target_link_libraries" section is important. I guess cmake just passes the list on to the linker as-is, i.e. it doesn't try and work out the correct order. This is reasonable - when you think about it cmake can't know what the correct order is until the linking is successfully completed.
Please add: CFLAGS="-lrt"
and LDFLAGS="-lrt"
Background
The DSO missing from command line
message will be displayed when the linker does not find the required symbol with it's normal search but the symbol is available in one of the dependencies of a directly specified dynamic library.
In the past the linker considered symbols in dependencies of specified languages to be available. But that changed in some later version and now the linker enforces a more strict view of what is available. The message thus is intended to help with that transition.
What to do?
If you are the maintainer of the software
You should solve this problem by making sure that all libraries that are needed to satisfy the needed symbols are directly specified on the linker command line. Also keep in mind that order often matters.
If you are just trying to compile the software
As a workaround it's possible to switch back to the more permissive view of what symbols are available by using the option -Wl,--copy-dt-needed-entries
.
Common ways to inject this into a build are to export LDFLAGS before running configure
or similar like this:
export LDFLAGS="-Wl,--copy-dt-needed-entries"
Sometimes passing LDFLAGS="-Wl,--copy-dt-needed-entries"
directly to make
might also work.
The same problem happened to me when I use distcc
to make my c++ project; Finally I solved it with export CXX="distcc g++"
.
The same thing happened to me as I was installing the HPCC benchmark (includes HPL and a few other benchmarks). I added -lm
to the compiler flags in my build script and then it successfully compiled.
If using g++
, make sure that you are not running gcc
instead
'Programming' 카테고리의 다른 글
.pid 파일이란 무엇이며 무엇을 포함합니까? (0) | 2020.05.18 |
---|---|
요소에서 모든 리스너를 제거하는 방법? (0) | 2020.05.18 |
C #에서 비동기 메소드를 어떻게 작성합니까? (0) | 2020.05.18 |
데이터베이스 대신 데이터 저장소에서 생각하는 방법? (0) | 2020.05.18 |
data.table이 다른 데이터에 대한 참조 인 경우를 정확히 이해하십시오. (0) | 2020.05.18 |