PDA

View Full Version : How does linker choose library?



daviddoria
16th June 2011, 12:02 AM
I am building a small program with 'g++ code.cpp -o myexe -L./subdir -lmylib'. In subdir/ there is a library called mylib.so and mylib.a.

First, how would it choose whether to link to the static or dynamic library?

Second, it builds, but when I try to run the executable it says "could not load library: could not find file mylib.so.2". Where is it getting this .2 from? I tried copying the .so to .so.2 but that didn't change anything.

Can anyone explain this at all?

Thanks,

David