When I’m compiling openvswitch-1.5.0, I’ve encountered the following compile error:
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
If I try to see the symbols of libpthread
, it looks fine.
$ 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
Could you give any hints or pointers?
jww
95k88 gold badges397 silver badges861 bronze badges
asked Nov 11, 2013 at 8:33
4
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
answered Nov 11, 2013 at 11:53
Michael PankovMichael Pankov
3,5312 gold badges22 silver badges31 bronze badges
2
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.
answered Mar 10, 2019 at 10:18
textshelltextshell
1,60613 silver badges21 bronze badges
4
The error message depends on distribution / compiler version:
Ubuntu Saucy:
/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
Ubuntu Raring: (more informative)
/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
Solution: You may be missing a library in your compilation steps, during the linking stage. In my case, I added ‘-lz’ to makefile / GCC flags.
Background: DSO is a dynamic shared object or a shared library.
answered Nov 26, 2013 at 0:34
KevinKevin
2,6611 gold badge27 silver badges30 bronze badges
5
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<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
answered Jul 14, 2016 at 13:34
EthourisEthouris
1,75113 silver badges18 bronze badges
3
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
answered Aug 29, 2016 at 16:43
osexp2003osexp2003
2,73428 silver badges26 bronze badges
1
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.
answered Dec 17, 2013 at 19:30
2
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.
answered Feb 5, 2015 at 9:31
AhrBAhrB
1111 silver badge3 bronze badges
If you are using CMake, there are some ways that you could solve it:
Solution 1: The most elegant one
add_executable(...)
target_include_directories(...)
target_link_libraries(target_name pthread)
Solution 2: using CMake find_package
find_package(Threads REQUIRED) # this will generate the flag for CMAKE_THREAD_LIBS_INIT
add_executable(...)
target_include_directories(...)
target_link_libraries(target_name ${CMAKE_THREAD_LIBS_INIT})
Solution 3: Change CMake flags
# e.g. with C++ 17, change to other version if you need
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pthread")
answered Apr 21, 2020 at 15:02
biendltbbiendltb
1,0591 gold badge12 silver badges20 bronze badges
Please add: CFLAGS="-lrt"
and LDFLAGS="-lrt"
Martin Evans
44.9k16 gold badges82 silver badges93 bronze badges
answered Apr 13, 2017 at 8:16
劉大為劉大為
1972 silver badges5 bronze badges
When working with code that uses mathematical functions, you should also link them.
In my Case when compiling I provided the following, which worked for me.
mpicc -o testname testname.c -lm
answered Jun 12, 2021 at 13:17
The same problem happened to me when I use distcc
to make my c++ project;
Finally I solved it with export CXX="distcc g++"
.
answered Feb 9, 2018 at 4:24
Jason GengJason Geng
591 silver badge8 bronze badges
Try to add -pthread
at the end of the library list in the Makefile.
It worked for me.
Ivan Aracki
4,61311 gold badges58 silver badges68 bronze badges
answered Nov 21, 2019 at 8:57
RickyRicky
791 silver badge8 bronze badges
if you are using cmake and used pthreads, try add the following lines
find_package(Threads)
target_link_libraries(${CMAKE_THREAD_LIBS_INIT})
answered Feb 1, 2020 at 14:56
bowman hanbowman han
1,07715 silver badges23 bronze badges
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.
answered Dec 4, 2016 at 18:41
1
If using g++
, make sure that you are not running gcc
instead
answered Jun 21, 2018 at 22:46
Martin R.Martin R.
1,40616 silver badges16 bronze badges
2
Compile with g++ instead. It has worked in my case switching from gcc to g++.
answered Jul 2, 2021 at 15:34
alienflowalienflow
3806 silver badges19 bronze badges
I have the same problem…
Please explain in detail, where add libx11, but rather correct, please build rules because lsd-slam is not going on any configuration (ROS + Ubuntu)
on Ubuntu 14.04 helped reinstall libx11*
Hi,
could you try to compile commit
116c6c9
(just use ‘git checkout 116c6c9’)
and see if that works?
Jakob
another solution should be to add X11 to the library list:
target_link_libraries(lsdslam ${FABMAP_LIB} g2o_core g2o_stuff csparse cxsparse g2o_solver_csparse g2o_csparse_extension g2o_types_sim3 g2o_types_sba X11)
in line 89 of lsd_slam_core/CMakeLists.txt.
possibly you also have to install the respective ubuntu package, but I suppose it’s already depended on somewhere. Just in case, run
sudo apt-get install libx11-dev
Please let me know if / what helped
Thanks Jakob. Your second solution worked.
i.e. Adding X11 to the line 89 of lsd_slam_core/CMakeLists.txt.
Thanks others for their replies as well.
Sorry for the late reply. I tried to uninstall X11 and reinstall, in the process I broke my Ubuntu installation :-). Hence reinstalled Ubuntu and everything else, got the above error again. Compilation was success after applying the fix by Jakob!
We could close the issue now!
another solution should be to add X11 to the library list:
target_link_libraries(lsdslam ${FABMAP_LIB} g2o_core g2o_stuff csparse cxsparse g2o_solver_csparse g2o_csparse_extension g2o_types_sim3 g2o_types_sba X11)
in line 89 of lsd_slam_core/CMakeLists.txt.
possibly you also have to install the respective ubuntu package, but I suppose it’s already depended on somewhere. Just in case, run
sudo apt-get install libx11-devPlease let me know if / what helped
![]()
Hi,
I have added X11 but still I am facing the same error.
I also want to know is there any difference between the following linking methods
- -lX11
- -L/usr/lib/X11
I’m trying to compile the download received here: https://code.google.com/p/linux-g13-driver/
by running make but I’m receiving errors that to me, after searching on the web, look like they’re the programmers fault but here they are:
g++ c-source/G13.o c-source/G13Action.o c-source/Macro.o c-source/MacroAction.o c-source/Main.o c-source/Output.o c-source/PassThroughAction.o -o Linux-G13-Driver -lusb-1.0
/usr/bin/ld: c-source/Main.o: undefined reference to symbol 'pthread_kill@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Linux-G13-Driver] Error 1
If anyone has any ideas please help I really want to get this running
Braiam
66.2k30 gold badges174 silver badges262 bronze badges
asked Sep 8, 2014 at 22:43
4
Edit the lines as shown below in the makefile and it should compile:
FLAGS = -L /lib64
LIBS = -lusb-1.0 -l pthread
answered Sep 8, 2014 at 23:10
HarrisHarris
2,57815 silver badges19 bronze badges
3
Я установил OpenCV в Ubuntu 14.04. Я пытаюсь найти учебники на сайте opencv. Я получил ошибку при запуске этого кода. Я использую затмение
запустить код. Я получаю эту ошибку при создании проекта.
Я добавил библиотеки opencv_core, opencv_highgui, opencv_imgcodecs в компоновщик g ++.
Error message:
//usr/local/lib/libopencv_imgproc.so.3.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [optest01] Error 1
Код:
#include "opencv2/imgproc.hpp"#include "opencv2/highgui.hpp"#include <stdlib.h>
#include <stdio.h>
using namespace cv;
/// Global variables
Mat src, src_gray;
Mat dst, detected_edges;
/** @function main */
int main( int argc, char** argv )
{
/// Load an image
src = imread( "/images/Lenna.jpg" );
if( !src.data )
{ return -1; }
/// Create a matrix of the same type and size as src (for dst)
dst.create( src.size(), src.type() );
/// Convert the image to grayscale
cvtColor( src, src_gray, COLOR_BGR2GRAY );
return 0;
}
1
Решение
Ваш код ошибки:
// USR / местные / Библиотека /libopencv_imgproc.so.3.0: ошибка при добавлении символов: DSO отсутствует в командной строке
говорит вам, что вы не связаны opencv_imgproc
,
Просто свяжите необходимую библиотеку:
-lopencv_imgproc
4
Другие решения
У меня была похожая проблема DSO missing from command line
и добавление -L/usr/local/lib
впереди решил проблему для меня, т.е. g++ source_code.cpp -o output_name -L/usr/local/lib <dependent libraries e.g. -lopencv_highgui>
1
когда я компилирую 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 '[email protected]@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 [email protected]@GLIBC_2.2.5
173: 0000000000008220 2814 FUNC LOCAL DEFAULT 13 __pthread_create_2_1
462: 0000000000008220 2814 FUNC GLOBAL DEFAULT 13 [email protected]@GLIBC_2.2
не могли бы вы дать какие-либо подсказки или указатели?
751
10
10 ответов:
вы должны упомянуть библиотеку в командной строке после объектные файлы, скомпилированные:
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
сообщение об ошибке зависит от дистрибутива / версии компилятора:
Ubuntu Дерзкий:
/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
Ubuntu 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
устранение: возможно, Вам не хватает библиотеки на этапах компиляции, на этапе компоновки. В моем случае я добавил ‘- lz’ для флагов makefile / GCC.
Справочная информация: 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
проблема в том, что командная строка не содержит
-lX11
— хотя libX11.so следует добавить в качестве зависимости, потому что в аргументах также были библиотеки GTK и GNOME.Итак, единственное объяснение для меня заключается в том, что это сообщение могло быть предназначено помочь, но он не сделал это должным образом. Это было, вероятно, просто: библиотека, которая предоставляет символ, не была добавлена в командную строку.
обратите внимание на три важных правила, касающиеся связи в POSIX:
- динамические библиотеки имеют определенные зависимости, поэтому только библиотеки из верхней зависимости должны быть предоставлены в любом порядке (хотя и после статических библиотек)
- статические библиотеки только неопределенные символы — это до вас, чтобы знать их зависимости и поставить все из них в команду линия
- порядок статический библиотеки всегда: истец впервые,провайдер следующее. В противном случае вы получите неопределенное символьное сообщение, как и тогда, когда вы забыли добавить библиотеку в командную строку
- при указании библиотеки с помощью
-l<name>
, вы никогда не знаете, будет ли он приниматьlib<name>.so
илиlib<name>.a
. Динамическая библиотека предпочтительна, если она найдена, а статические библиотеки могут быть применены только с помощью параметра компилятора-это все. И есть ли у вас какие-либо проблемы, как указано выше, это зависит от того, были ли у вас статические или динамические библиотеки- ну, иногда зависимости могут отсутствовать в динамических библиотеках: D
Я обнаружил, что у меня была та же ошибка. Я компилировал код как с lapack, так и с blas. Когда я переключил порядок, что две библиотеки были вызваны ошибка ушла.
«LAPACK_LIB = — llapack-lblas» работал где
«LAPACK_LIB = — lblas-llapack» выдал ошибку, описанную выше.
Я также столкнулся с той же проблемой. Я не знаю, почему, я просто добавить
-lpthread
опция для компилятора и все в порядке.старый:
$ g++ -rdynamic -m64 -fPIE -pie -o /tmp/node/out/Release/mksnapshot ...*.o *.a -ldl -lrt
получил следующее сообщение об ошибке. Если я добавлю
-lpthread
опция выше команды, то ОК./usr/bin/ld: /tmp/node/out/Release/obj.host/v8_libbase/deps/v8/src/base/platform/condition-variable.o: undefined reference to symbol '[email protected]@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
Я обнаружил, что иногда библиотека, на которую жалуется компоновщик, не является причиной проблемы. Возможно, есть умный способ решить, где проблема, но это то, что я делаю:
- закомментируйте все связанные библиотеки в команде link.
- очистить все .o’s,. so и т. д. (Обычно достаточно очистить, но вы можете запустить рекурсивный find + rm или что-то подобное).
- раскомментируйте библиотеки в ссылке команда по одному за раз и перестроить порядок по мере необходимости.
@peter karasev: я столкнулся с той же проблемой с проектом gcc 4.8.2 cmake на CentOS7. Важен порядок библиотек в разделе «target_link_libraries». Я предполагаю, что cmake просто передает список компоновщику как есть, т. е. он не пытается выработать правильный порядок. Это разумно — когда вы думаете об этом cmake не может знать, что правильный порядок, пока связь не будет успешно завершенный.
пожалуйста, добавьте:
CFLAGS="-lrt"
иLDFLAGS="-lrt"
то же самое произошло со мной, когда я устанавливал тест HPCC (включая HPL и несколько других тестов). Я добавил
-lm
к флагам компилятора в моем скрипте сборки, а затем он успешно скомпилирован.
та же проблема случилась со мной, когда я использую
distcc
сделать мой проект c++ ;
Наконец я решил его сexport CXX="distcc g++"
.
при использовании
g++
убедитесь, что вы не используете
0
2
Снова ошибка при сборке, только теперь другая?
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/../../../../lib64/libdl.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:411: recipe for target 'emerald' failed
make[2]: *** [emerald] Error 1
make[2]: Leaving directory '/var/tmp/portage/x11-wm/emerald-0.9.5/work/emerald-0.9.5/src'
Makefile:434: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/var/tmp/portage/x11-wm/emerald-0.9.5/work/emerald-0.9.5'
Makefile:365: recipe for target 'all' failed
make: *** [all] Error 2
emake failed
* ERROR: x11-wm/emerald-0.9.5::x-portage failed (compile phase):
* emake failed
*
* Call stack:
* ebuild.sh, line 93: Called src_compile
* environment, line 2953: Called default
* phase-functions.sh, line 770: Called default_src_compile
* phase-functions.sh, line 807: Called __eapi2_src_compile
* phase-helpers.sh, line 697: Called die
* The specific snippet of code:
* emake || die "emake failed"
*
* If you need support, post the output of `emerge --info '=x11-wm/emerald-0.9.5::x-portage'`,
* the complete build log and the output of `emerge -pqv '=x11-wm/emerald-0.9.5::x-portage'`.
* The complete build log is located at '/var/tmp/portage/x11-wm/emerald-0.9.5/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/x11-wm/emerald-0.9.5/temp/environment'.
* Working directory: '/var/tmp/portage/x11-wm/emerald-0.9.5/work/emerald-0.9.5'
* S: '/var/tmp/portage/x11-wm/emerald-0.9.5/work/emerald-0.9.5'
>>> Failed to emerge x11-wm/emerald-0.9.5, Log file:
>>> '/var/tmp/portage/x11-wm/emerald-0.9.5/temp/build.log'
* Messages for package x11-wm/emerald-0.9.5:
* ERROR: x11-wm/emerald-0.9.5::x-portage failed (compile phase):
* emake failed
*
* Call stack:
* ebuild.sh, line 93: Called src_compile
* environment, line 2953: Called default
* phase-functions.sh, line 770: Called default_src_compile
* phase-functions.sh, line 807: Called __eapi2_src_compile
* phase-helpers.sh, line 697: Called die
* The specific snippet of code:
* emake || die "emake failed"
*
* If you need support, post the output of `emerge --info '=x11-wm/emerald-0.9.5::x-portage'`,
* the complete build log and the output of `emerge -pqv '=x11-wm/emerald-0.9.5::x-portage'`.
* The complete build log is located at '/var/tmp/portage/x11-wm/emerald-0.9.5/temp/build.log'.
* The ebuild environment file is located at '/var/tmp/portage/x11-wm/emerald-0.9.5/temp/environment'.
* Working directory: '/var/tmp/portage/x11-wm/emerald-0.9.5/work/emerald-0.9.5'
* S: '/var/tmp/portage/x11-wm/emerald-0.9.5/work/emerald-0.9.5'
когда я компилирую 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
не могли бы вы дать какие-либо подсказки или указатели?
10 ответов
вы должны упомянуть библиотеку в командной строке после объектные файлы, скомпилированные:
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
115
автор: Michael Pankov
сообщение об ошибке зависит от дистрибутива / версии компилятора:
Ubuntu Дерзкий:
/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
Ubuntu 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
устранение: на этапе компоновки может отсутствовать библиотека в шагах компиляции. В моем случае я добавил’ — lz ‘ к флагам makefile / GCC.
Справочная информация: 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
проблема в том, что командная строка не содержит -lX11
— хотя libX11.поэтому следует добавить как зависимость, потому что в аргументах также были библиотеки GTK и GNOME.
Итак, единственное объяснение для меня заключается в том, что это сообщение могло быть предназначено для помочь, но он не сделал этого должным образом. Это было, вероятно, простой: библиотека, предоставляющая символ, не была добавлена в командную строку.
обратите внимание на три важных правила, касающиеся связи в POSIX:
- динамические библиотеки имеют определенные зависимости, поэтому только библиотеки из верхней зависимости должны быть предоставлены в любом порядке (хотя после статических библиотек)
- статические библиотеки имеют только неопределенные символы — это зависит от вас, чтобы узнать их зависимости и предоставить все из них в команде линия
- порядок static библиотеки всегда: истец впервые, провайдер следующее. В противном случае вы получите неопределенное символьное сообщение, как когда вы забыли добавить библиотеку в командную строку
- при указании библиотеки с
-l<name>
, вы никогда не знаете, будет ли он приниматьlib<name>.so
илиlib<name>.a
. Динамическая библиотека предпочтительнее, если она найдена, а статические библиотеки могут применяться только с помощью опции компилятора — это все. И есть ли у вас какие-либо проблемы, как указано выше, это зависит от того, были ли у вас статические или динамические библиотеки - ну, иногда зависимости могут отсутствовать в динамических библиотеках: D
Я обнаружил, что у меня была такая же ошибка. Я компиляции кода с lapack и Блас. Когда я переключил порядок вызова двух библиотек, ошибка исчезла.
» LAPACK_LIB = -llapack-lblas » работал там, где
«LAPACK_LIB = -lblas-llapack» дал ошибку, описанную выше.
Я также столкнулся с той же проблемой. Не знаю почему, просто добавляю -lpthread
опция компилятора и все в порядке.
старый:
$ g++ -rdynamic -m64 -fPIE -pie -o /tmp/node/out/Release/mksnapshot ...*.o *.a -ldl -lrt
получил следующее сообщение об ошибке. Если я добавлю -lpthread
опция для команды выше, затем 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
Я обнаружил, что иногда библиотека, на которую жалуется компоновщик, не является причиной проблемы. Возможно, есть умный способ выяснить, где проблема, но это то, что я делаю:
- прокомментируйте все связанные библиотеки в команде link.
- очистить все .o’s,.так и т. д. (Обычно достаточно очистить, но вы можете запустить рекурсивный find + rm или что-то подобное).
- раскомментируйте библиотеки по ссылке командуйте по одному и при необходимости меняйте порядок.
@peter karasev: я столкнулся с той же проблемой с проектом gcc 4.8.2 cmake на CentOS7. Порядок библиотек в разделе «target_link_libraries» важно. Я думаю, cmake просто передает список компоновщику как есть, т. е. он не пытается выработать правильный порядок. Это разумно — когда вы думаете об этом, cmake не может знать, что такое правильный порядок, пока соединение не будет успешно завершенный.
пожалуйста, добавьте: CFLAGS="-lrt"
и LDFLAGS="-lrt"
то же самое произошло со мной, когда я устанавливал тест HPCC (включает HPL и несколько других тестов). Я добавил -lm
к флагам компилятора в моем скрипте сборки, а затем он успешно скомпилирован.
та же проблема произошла со мной, когда я использую distcc
сделать мой проект c++ ;
Наконец, я решил это с export CXX="distcc g++"
.
при использовании g++
убедитесь, что вы не используете
I am attempting to install rejoystick, and when I run make, I get this:
Making all in src
make[1]: Entering directory '/home/chrx/Downloads/joystick/rejoystick-0.8.1/src'
make[2]: Entering directory '/home/chrx/Downloads/joystick/rejoystick-0.8.1/src'
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -std=iso9899:1990 -Wall -pedantic -I../include -O2 -s -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -o rejoystick assign_button.o backend.o button_axis.o error.o io.o js_axis.o js_button.o list.o main.o sdl_misc.o -lXtst -lgthread-2.0 -pthread -lglib-2.0 -L/usr/lib/x86_64-linux-gnu -lSDL -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lfontconfig -lfreetype -lglib-2.0
gcc -g -O2 -std=iso9899:1990 -Wall -pedantic -I../include -O2 -s -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -o rejoystick assign_button.o backend.o button_axis.o error.o io.o js_axis.o js_button.o list.o main.o sdl_misc.o -pthread -lXtst -lgthread-2.0 -L/usr/lib/x86_64-linux-gnu -lSDL -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lfontconfig /usr/lib/x86_64-linux-gnu/libfreetype.so -lglib-2.0 -Wl,--rpath -Wl,/usr/lib/x86_64-linux-gnu -Wl,--rpath -Wl,/usr/lib/x86_64-linux-gnu
/usr/bin/ld: io.o: undefined reference to symbol 'XKeycodeToKeysym'
/usr/lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:277: recipe for target 'rejoystick' failed
make[2]: *** [rejoystick] Error 1
make[2]: Leaving directory '/home/chrx/Downloads/joystick/rejoystick-0.8.1/src'
Makefile:335: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/chrx/Downloads/joystick/rejoystick-0.8.1/src'
Makefile:248: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
What can I do to fix this? (I’m guessing the error is error adding symbols: DSO missing from command line
)
Jeff Schaller♦
65.2k34 gold badges106 silver badges240 bronze badges
asked Jul 3, 2019 at 12:57
0
The build is missing -lX11
; to work around that, run
./configure LIBS=-lX11 && make
answered Jul 3, 2019 at 13:16
Stephen KittStephen Kitt
388k51 gold badges996 silver badges1095 bronze badges
0
# (отредактировано 5 лет, 7 месяцев назад) |
|
Темы: 122 Сообщения: 1571 Участник с: 08 октября 2015 |
в общем имеется арч, собираемая прога вывод процесса компиляции:
интересует именно строка
в которой видно откуда берет линкуемую либу компилятор, но ведь насильно указана либа boost37
почему он не линкует из ентого пути и как его все же уговорить енто делать? |
slavutich |
# |
Темы: 28 Сообщения: 170 Участник с: 28 марта 2014 |
попробуйте export BOOST_LIB_PATH=/usr/lib/boost37 |
safocl |
# |
Темы: 122 Сообщения: 1571 Участник с: 08 октября 2015 |
не, енто ничо не даст, просто export будет распространяться дальше на сессию, а такое указание параметра будет тока на данную команду распространяться |
vasek |
# (отредактировано 5 лет, 7 месяцев назад) |
Темы: 47 Сообщения: 11417 Участник с: 17 февраля 2013 |
Насколько я понимаю, логи
говорят о том, что это ошибка DSO и причина не в твоей библиотеке, а, предположу, в отсутствии зависимостей/библиотек boost::system и железная голова намекает добавить в командную строку эти зависимости. PS … По этим ошибкам сразу же вышел на это и это Ошибки не исчезают с опытом — они просто умнеют |
safocl |
# (отредактировано 5 лет, 7 месяцев назад) |
Темы: 122 Сообщения: 1571 Участник с: 08 октября 2015 |
так оно есть в мейкфайле…
на 32 строке |
vasek |
# |
Темы: 47 Сообщения: 11417 Участник с: 17 февраля 2013 |
Значит не знает ентого пути, точнее не знает (не понимает) твой BOOST_LIB_PATH
Ошибки не исчезают с опытом — они просто умнеют |
safocl |
# |
Темы: 122 Сообщения: 1571 Участник с: 08 октября 2015 |
так он ентот вывод и дает потому чо берет линк с либой не той версии |
vasek |
# |
Темы: 47 Сообщения: 11417 Участник с: 17 февраля 2013 |
Ты в этом уверен на все 100 ??? Ошибки не исчезают с опытом — они просто умнеют |
vasek |
# (отредактировано 5 лет, 7 месяцев назад) |
Темы: 47 Сообщения: 11417 Участник с: 17 февраля 2013 |
safocl, а не проще сделать свою библиотеку, точнее превратить эту либу в статическую? PS … заодно и проверится — а в этой ли библиотеке затык. PSS … и я бы потрейсил, чтобы точно узнать — находится эта библиотека или нет. Ошибки не исчезают с опытом — они просто умнеют |
safocl |
# |
Темы: 122 Сообщения: 1571 Участник с: 08 октября 2015 |
а енто как?
ну на все 100 нет, но с актуальной версией ента прога не собирается… |