error adding symbols: DSO missing from command line

What are the eight life cycle hook functions of Vue>>>

Recently, when I was working on the project, I encountered a lot of thorny problems when compiling the code, and the information on the Internet was relatively small. On the issue of appeal, I just want to say look

DSO missing from command line: Causes and solutions. Only after reading the introduction of this article can I have a better understanding of this error

In other words, if Library B relies on library a for static compilation, then Library B will have the link information of Library A. let’s talk about the error

$ g++ main.cpp -lA -lB -o main  

Will output

/usr/bin/ld: /usr/local/lib/libB.a(main.cpp.o): undefined reference to symbol '_a_symbol_name'
/usr/local/lib/libA.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

At that time, the blogger said that in binutils & lt; There was no problem on 2.22, but there was a problem later

This should be a compilation problem. LD automatically recursively parses the linked lib. When library a is loaded, everything is normal. However, when Library B is loaded, LD automatically parses its static links, so it repeats, causing error adding symbols. So there’s no problem with the next one

$ g++ main.cpp -lB -lA -o main  

In this way, the compilation is normal and the program can run normally

As for the sequence of link libraries, I have read the article about the sequence of link libraries. Normally, when a link dynamically connects to a library, it starts from left to right. If there is a sequence error, GCC will help us to relocate it automatically. I think the way to ensure it is to do a good job in the sequence of the library

I’ll sort out the link order here

high level static link library

underlying dependency Library

high level dynamic link library

other unrelated Libraries

….fuck,fuck! Rewriting twice, the first power can understand, the second inexplicably turned off the computer, come on, we are civilized people, this is just a small episode, we continue

Similar Posts: