[ back to toc ]

Project organization - C program and Unix

Date: 2002/02/10 12:25

I have a project I am working on that when I opened the .tar file it
exploded in directories and I don't exactly understand the purpose of
using such a directory structure to work in. The structure is this:

from my home directory /project1:

from project1/src:

from project1/src/bin

from project1/src/lib

Now I understand what each of the directories contain, but what I don't
get is why I have to have a /lib and /bin directory under /project1 and
also under project1/src. An "install target" in a makefile ends up
copying the executables and libraries out of the projct1/src/ bin and lib
directories into the project1/lib and bin directories - duplicates!

Also why do libary files and executables get placed in different
directories, why can't they be in the same directory? Both executables
use the same library files.

Sorry if this is confusing, all these directories are confusing "ME!"

And one more thing about the install target in the library make file: it
uses the -s option. The install target for the executables makefile
install -c ${RELLIB} -s -m 775 ${LIB}
install -c ${RELBIN} -m 755 ${EXEC}

(RELLIB=../../../lib and RELBIN=../../../bin)
As far as I can tell from the man pages the -s option just means to
supress messages other than error messages so I don't see why you'd use
the option for a library and not an executable.

Needless to say that the universe is more than what we can understand and
such is the programmer brain being part of it. You may feel, but may not
understand such a structure. If you developed that program, you would have
used a different structure. Another programmer used other structure. Do
not make more problems than those that you really have to solve.

I can easily imagine that install uses -s in once case, because the
programmer wanted tpo supress warnings, and not in the other just because
he or she simply forgot it.

I do not really see the importance of the directory structure in this

Having files copied may have some reason in case during development you
may overwrite them, and still have the original.

Why do not you ask the developer, who organized this that way if you are
really curious and die unless to find out why the directory structure is
that way? Really. I am serious, I am not smiling, I mean it. Ask her (him)
being polite putting ladies first.

So I believe there is no reasom more than that is happened that way when
one programmed it.

Oh how I wish I COULD get an answer from the one who programmed it. I am
in an on-line "Advanced Unix with C" class and have happened upon an
instructor who believes in divine interpretation and is short on
explanation. What I have asked you are pointed questions I was to have
been able to make sense of on my own - there is some cosmic reasoning for
the directory structure, and the use of -s for the library and not the
executable was deliberate. I have scoured all my books, the internet and
written the prof. It just happens once in a while you get a prof that is
not very good corresponding, and this happens to be one of them, and since
my understanding this is probably core to my upcoming "graded" projects, I
figured I better try to get a grasp on this.

Well, *NAME-DELETED* in this case this is a real trouble. I can not tell you the
answer for sure, and I think that no-one but the prof can tell what is in
his mind.

However: I am a bit angry with you, because you ask me questions and you
did nto pay attention to reading documentation. The -s option to install
(at least on Linux) strips the symbols from the file. This means that in
case you use this option you get an undebuggable executable. I do not know
why he uses it on libs. Most probably, because the libs are treated as
checked and fully debugged and need no symbolic information.

But I have never used install and have no experience. This is just that I
read in the man install.

The option -c is ignored on Linux.

The reason for copiing the lib files and create duplicates can be very
easily explained. Assume that you have a source distribution and then you
compile and want to create a binary tarball containing the binaries. For
this you have to put all the binaries into a directory structure that is
rooted froma sinlge directory and contains nothing else but the binaries.

To put the executable and the library files into different file can also
be easily explained. Assume that you want to deliver this binary tarbal
you just have created onto another machine and install your program to
work for all users. This means that you have to copy all the executables
into /usr/local/bin (or into some similar location) and the libraries into
/usr/local/lib (for example). If you have all executables and libraries
mixed up in a sinlge directory that you can not write a simple script to
separate them. If they are in different directories then you can copy the
comtent of one into one dir and the other into the other one.

Note that in your case you may only have a few exe files adn lib files,
but in a larger project you may have quite a lot!

I hope this helped.


[ back to toc ]