|
From: David E. <de...@us...> - 2005-07-12 03:47:45
|
BB wrote: > I want to compile and link a program as a > shared library, but am running into problems. > > As soon as I add the "LINKAGE SECTION" and > place "USING.." on the "PROCEDURE DIVISION" line > of my Cobol program, it crashes during the link stage. > > Here is how I compiled it... > > # First we compile the program $PROG to produce the .o file > htcobol -c -g -C -D -F -P -I $COBCPY $PROG.cbl > # -c Compile to a statically linked object module. > # -g Generate Compiler debugging output > # -C Make all Cobol calls dynamic > # -D Include Source Debugging Lines > # -F Input Source is in standard Fixed Column format > # -P Generate Output Listing file > # -I Define include (copybooks) search path(s). > > Here is how I linked it... > > # Next we create the Dynamically Loadable Shared Library "scn.so.0.0" > gcc -shared -Wl,-soname,lib$PROG.so.0.0 -o lib$PROG.so.0.0 $PROG.o > > Here is the output produced by "gcc". > --------------------------------------- > The program compiled successfully! > Linking glcosch.o... > /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crt1.o: In function > `_start': > /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crt1.o(.text+0x18): > undefined reference to `main' > collect2: ld returned 1 exit status > ---------------------------------------- I think the problem is with TC version 0.62, which tries to auto detect if program is a main or sub-program, is generating a main entry point. Check that your sub-program has a 'LINKAGE SECTION' and at least one variable defined. Example: LINKAGE SECTION. 01 VAR PIC X(10). PROCEDURE DIVISION USING VAR. To aviod these headaches, you could download the current CVS version which has command line options to better deal with entry points and sub-programs. |