You can't give anybody a '.o' file.
Put floppy disk in computer.
Copy *.o to floppy disk.
Take floppy disk out of computer, give it to someone.
I've just given someone a load of .o files.
"You can't give anybody a '.o' file" is just plain untrue.
The '.o' file is an output that depends on the brand of compiler you
use. One compiler's object file may not be compatible with another
brand of compiler, linker or another version of the same compiler.
Which century are you in? That may have been true 20 years ago, but
these days we have stardards for such things.
It is very common in the commercial world to do "binary releases"
of software in object or library (collection of object files) form, to
protect the source, all you have to do is to make sure that you compile
them with compatible software to that of the person using them.
In practice, most compilers in the Windows world produce compatible
object files at least for C (C++ name mangling is a different matter),
and they do for a single platform in the Unix world as well. How do you
think standard libraries work? On my Debian GNU/Linux system I have
dozens (at least) of libraries supplied in object form, they don't need
recompiling if I install a new version of the compiler (or even another
compiler on that system). Even Gentoo, which is a GNU/Linux
distribution where almost everything is compiled from source by the
installer, distributes object files and libraries of object files to get
started (to build an application you need to have the standard libraries
and object files first before you can compile it).
It's called "binary compatibility", and is something compiler and
library writers spend a lot of time making sure that they get right so
that people don't have to build everything from source all the time.
What's worse is that the object file may not be portable across
platforms either.
So you produce them for the appropriate platform. At work we produce
object files for Windows, GNU/Linux-x86 and ARM (which has a published
standard ABI) for distribution, you are given (sold) the version
appropriate for your use. If we had customers who used other systems we
would produce the object files for those as well (we might charge a
'setup' fee if it meant us buying extra hardware or software to produce
them).
Before you recommend sharing of '.o' files, please have more
information ready or state the warning.
How would you go about giving someone code for them to use but they
aren't allowed to see?
Chris C