Answer:
Assuming those methods are in one of the libs it looks like an ordering problem.
When linking libraries into an executable they are done in the order they are declared.
Also the linker will only take the methods/functions required to resolve currently oustanding dependencies. If a subsequent library then uses methods/functions that were not originally required by the objects you will have missing dependencies.
How it works:
Objects requires:
But if I linki the application like this:
When linking libraries into an executable they are done in the order they are declared.
Also the linker will only take the methods/functions required to resolve currently oustanding dependencies. If a subsequent library then uses methods/functions that were not originally required by the objects you will have missing dependencies.
How it works:
- Take all the object files and combine them into an executable
- Resolve any dependecies among object files.
- Foreach library in order:
- Check unresolved dependencies and see if the lib resolves them.
- If so load required part into the executable.
Objects requires:
- Open
- Close
- BatchRead
- BatchWrite
- Open
- Close
- read
- write
- BatchRead (but uses lib1:read)
- BatchWrite (but uses lib1:write)
gcc -o plop plop.o -l1 -l2Then the linker will fail to resolve the read and write symbols.
But if I linki the application like this:
gcc -o plop plop.o -l2 -l1Then it will link correctly. As l2 resolves the BatchRead and BatchWrite dependencies but also adds two new ones (read and write). When we link with l1 next all four dependencies are resolved.