# a suggestion to solve library dependency problem



## jronald (Mar 24, 2010)

For instance, there are two applications, A and B.
A depends on two libraries, LA and LC.
B depends on two libraries, LB and LC.

after installation, the layout can be as below:


```
/usr/app/A/A  # the executable
/usr/app/A/LA
/usr/app/A/LC # soft/hard link to /usr/lib/LC, or a standalone one

/usr/app/B/B  # the executable
/usr/app/B/LB
/usr/app/B/LC # soft/hard link to /usr/lib/LC, or a standalone one

/usr/lib/LC

# and /usr/bin can some place like destop, and links can be put there
/usr/bin/A # soft link to /usr/app/A
/usr/bin/B # soft link to /usr/app/B
```

The main benifit is that the integrality of the application can be kept in one directory,
it is a good start. And it is also compatible with the current situation.

LC can be a soft link or a hard link.
When a hard link, it's good for uninstallation, not good for installation.
When uninstallation, just delete the app's directory, and in "/usr/lib/", if a lib file's reference number is 1, it can be deleted or kept upon the user. When installation, error ocurrs when an shared library file doesn't exist.

When a soft link, it's good for installation, not good for uninstallation.
When installation, a soft link can always be created. When uninstallation,
the shared libraries are not so easy to clear if demanded.

If the app has the duty to install its shared library, it should be a hard link, because it is likely to have the duty to uninstall its shared library.
If the app has no duty to install its shared library, it should be a soft link, and the needed shared library can be determined by the links, and installed manually.

If the dependency makes sense, soft link is a good choice, it can be enjoyable to learn the dependecies on shared libraries, and use the app more efficiently. (But when I install xorg, it shows that it depends on some libraries named *gnome*/*kde*, it's reversed, isn't it? So I'd  like not to install it manually.) The port system knows what dependencies to install, but it doesn't know how to uninstall them. What abou this:
1. use soft link when install
2. make soft link hard for uninstallation
It's late binding, and bind only once.


----------

