Worked Out Shared Libs
Posted in 1995
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
To all, Thanx to all who helped me in accomplishing the 'shared libs' scenario !!!!! Below are the steps to create Shared Libs out of Informix 4GL. There are a few advantages, the main one the the main programs do not have to be recompiled each time the libraries are changed !!!!! I would appreciate all views , thanx. --------------->---------------->--------------------->------- 7th July 1995 Page #1 by Manoj S. Building Shared Libraries on the IBM RS6000 / AIX for Informix Source _____________________________________________________________________ (manoj@dspdev.dalsys.co.uk) a. Compile all .4gl's , except the main 4gl or the 4gl's that are not to be shared (i.e. non library stuff) to .o's . c4gl -c <program.4gl> b. Compile all .ec's to .o's using. for i in *.ec do y=`echo ${i}|sed 's:\\.ec:\\.o:'` c=`echo ${i}|sed 's:\\.ec:\\.c:'` esql -I/dsc/lib/sys/incl -I/dsc/lib/trp/incl -I/dsc/lib/fac/incl \\ -I/dsc/lib/am/incl -I/informix/incl -L /dsc/lib -L /informix/lib \\ -c /dsc/bin/manoj/${i} -o ${y} rm -f ${c} done c. Compile all .c's to .o's using cc. for i in *.c do cc -I/dsc/lib/sys/incl -I/dsc/lib/trp/incl -I/dsc/lib/fac/incl \\ -I/dsc/lib/am/incl -I/informix/incl -L /dsc/lib -L /informix/lib \\ -c /dsc/bin/manoj/${i} done d. Generate tags file. ctags *.c e. Convert tags file to .exp file. cat tags|awk '{ print $1 }' > abc mv abc <file.exp> The first line of the <file.exp> should be: #! <shr<file>.o + full path> (full path where the shared lib will reside) The <file.exp> contains a list off all functions in the shared libs. f. Prepare all .o's to .a's. ar vq <file.a> *.o (or, ar vr <file.a> <xxx.o>, to revise the <file.a> with newer version of .o) g. Execute the line below : cc -O -s -o <shr<file>.o> \\ <file.a + full path> \\ -bE:<file.exp> -bM:SRE -e _nostart \\ -I/informix/incl /informix/lib/lib4gl.a /informix/lib/libnforms.a \\ /informix/lib/libfesql.a -lbsd -T512 -H512 -lc You have now created a shared library called <shr<file>.o> Page #2 Explanation: -TNumber Makes the value of the Number variable the starting ad- dress for the text segment of the output file. The default value is 0. Note: The system loader relocates the .text section at runtime, so the specified number affects only addresses listed in address maps or printed by utilities such as the dump or nm command. -HNumber Makes the value of the Number variable the boundary to which the .text, .data, and .loader sections are aligned within the output object file. To perform the specified file boundary alignment, the binder inserts a pad section of an appropriate size prior to the .text, .data, and .loader sections of the out- put object file. If the value of the Number variable is 0, no padding is inserted. -lKey Processes the libKey.a file, which is located in one of the directories specified by the -L flag or the standard library directory (/usr/lib). The files specified with this argument are searched in the order specified, along with the input object files and all the files specified with the -f flag. This flag can be repeated. (l is the lowercase letter L.) In this version of the ld command, the first definition of each symbol in the link always takes precedence and is used even if the first reference follows the definition. -b RE Reusable. Module requires a private copy of the data area for each process dependent on the module. If an S prefix is used on any of the above options, the shared flag in the object file is set. The system loader ignores the module types field. The system loader will attempt to share a single instance of the .data section of an RO module. Otherwide, the module type is ig- nored by the system loader. The default value is 1L. h. Compile the main program with the shared library. c4gl -o <result-program> <main-program> \\ <shr<file>.o> -Lfull path of <shr<file>.o> You may change the shared libs <shr<file>.o> without having to recompile the main source. The only thing is the if you are changing/deleting/adding a function the make sure that the <file>.exp reflects these changes.