views:

41

answers:

1

This is a question I've come across repeatedly, usually concerning plug ins, but recently I came across it trying to hammer out some build system issues. My concern is primarily for *nix based systems, but I suppose it applies to windows as well.

The question is, what is the minimum amount of information necessary to do dynamic linking? I know linux distributions like Debian have simply an 'i686', which is enough. However, I suppose there is some implicit information here, and I probably won't be able to do dynamic linking of any shared object as long as they're compiled using -march=i686, will I?

So what must be matched correctly for me to be able to load a shared object successfully? I know that for c++ even the compiler (and sometimes version) must match due to name mangling, but I was kind of hoping this wasn't the case for c.

Any thoughts appreciated.

Edit:
Neil's answer made me realize I'm not really talking about dynamic linking, or rather, the question is two-fold,

  1. what's needed for static linking, and
  2. what's needed for dynamic linking

I have higher hopes for the first I guess.

+2  A: 

Well at minimum, the code must have been compiled for the same processor family, and you need to know the names of the library and the function. On top of that, you need the same ABI. You should be aware that despite what people think, the C Standard does not specify an ABI and it is entirely possible for two C compilers (or versions of the same compiler) to adhere to the standard, run on the same platform, but have different ABIs.

As for exactly specifying architecture details - I must admit I've never done it. Are you planning on distributing binary libraries on different Linux variants?

anon
What I'm currently considering is a build system where I'm able share build results, rather than having to compile everything every time, and the point here being I need to compile one library for each combination of properties that we have here, like i686 linux, sparc solaris and a proprietary ppc-based platform, so that each developer can simply link their work to these prebuilt libraries.
roe
As I abhor acronyms, I'm adding it here to clarify for others: ABI is Application Binary Interface. See: http://en.wikipedia.org/wiki/Application_binary_interface
Thomas Matthews