Re: Setting up libraries
Posted in 1998
There is a difference between archive libraries and shared libraries. Archive libraries (if I remember the terminology) are linked to the program at compile time. When you make a change to the library you have to relink the program. Shared libraries are linked to the program at run time so when you update the library the program gets the newest version at run time. The only advantage of archive libraries over shared libraries is that if you want to copy the program to another system then you only have to copy the executable, not the associated archive libraries. The advantages of shared libraries are numerous. Besides the run-time linking mentioned above, if more than one program uses a shared library then only one copy of the library is loaded into memory. Disc space is also conserved. Setting up shared libraries varies between platforms. I found a way to put 4gl programs into shared libraries (libxxx.sl) on hp-ux, something like: c4gl -c -shared module1.4gl c4gl -c -shared module2.4gl c4gl -c -shared module3.4gl cc -c +z cfuncs.c ld -b -s -o libxa.sl module1.o cfuncs.o ld -b -s -o libxb.sl module2.o module3.o c4gl -c main.4gl c4gl -shared -o main.4ge main.o -s -L. -lxa -lxb The SHLIB_PATH environment variable can point to the location of the libraries at run time. David wrote: > > Hi, > > Having previously worked on 4GL V4, I used to create libraries like > this: > > ar -rs libdriver.a some_function1.o some_function2.o > cp libdriver.a /lib > > Then, if any of the functions included in the library were re-compiled > and the libdriver.a updated, there was no need to re-compile any other > program that used these functions. I think this was becuase the other > programs will have been compiled and linked with libdriver.a and so at > runtime they would call up the new function. > > Now that I am working with RDS V4.20 and SE 5.10 I don't think I have > this option anymore. > > Can anyone suggest a way of creating re-useble functions that can be > called upon without having to re-compile other program that would want > to use them? > > Any advice given would be very welcome. > > Cheers, David. ________________________________________________________________ John H. Frantz Power-4gl: Extending Informix-4gl john@rl.is http://www.rl.is/~john/pow4gl.html