[cs631apue] Last Questions

Jan Schaumann jschauma at stevens.edu
Tue Dec 3 13:16:36 EST 2019


Mario P Alexandre <malexan3 at stevens.edu> wrote:
 
>   1.  If I created an executable that relied on my own created library files, how would I share the library files and the executable with another system if the library files were dynamically linked in the executable?

You would have to provide the library as well.  So
e.g., if your application 'myexec' is linked against
libc, libmath, libcrypto, and your own libmyexec, then
you would typically provide as a distribution for
others:

bin/myexec
lib/libmyexec.so -> libmyexec.so.1
lib/libmyexec.so.1 -> libmyexec.so.1.1
lib/libmyexec.so.1.1

and require users to install these files such that the
library is found at runtime by the link loader.

>   2.  What would be the reasoning and use case behind the use of the fPIC compiler flag?

Per the compiler's manual page:

    If supported for the target machine, emit position-independent
    code, suitable for dynamic linking and avoiding any limit on the
    size of the global offset table.

That is, if you want to create a shared library such
that it can be dynamically linked, the code may need
to be specifically generated to not make assumptions
about where it resides within the process image.

>   3.  Do you have any examples of simple containers?

I think Docker is probably the most widely-used and
easiest to use container framework.  As discussed in
our last class, you can effectively build your own
container according to your needs via the various
methods we discussed, but while that would be "simple"
from a technical perspective, it requires a fair deal
of understanding.

Docker, on the other hand, can easily be run by
non-experts.

https://docker-curriculum.com/ is a good tutorial to
get started.

-Jan


More information about the cs631apue mailing list