|
From: BB <be...@by...> - 2005-07-11 07:43:37
|
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 ---------------------------------------- Jim Morcombe (Still using Ben's computer, and wishing the 24 hour warranty on his own PC really meant something less than a week! Why did he ever trade in his trusty old Windows 98 PC? What was wrong with his Windows 95 PC? At least his old ancient Linux box and even more ancient ancient SCO boxes still work faithfully.) |
|
From: Jim M. <ro...@vi...> - 2005-07-12 09:13:13
|
David
Yes, I have a LINKAGE SECTION with a number of variables.
Jim
Here is my linkage section.
018600******************************************************************
018700* LINKAGE SECTION *
018800******************************************************************
020100 LINKAGE SECTION.
020300 77 PROG-NAME PIC X(6).
020400 77 PROG-DESC PIC X(40).
77 SEARCH-COMPANY PIC X(05).
77 SEARCH-ACCOUNT PIC X(20).
020600 77 ACCOUNT-DESC PIC X(40).
020700 77 PF-KEY PIC 99.
020800 77 ERROR-CODE PIC 99.
020900
021000/
021100******************************************************************
021200* PROCEDURE DIVISION *
021300******************************************************************
021400 PROCEDURE DIVISION USING PROG-NAME,
021500 PROG-DESC, SEARCH-COMPANY,SEARCH-ACCOUNT
ACCOUNT-DESC,
021600 PF-KEY, ERROR-CODE.
|
|
From: David E. <de...@us...> - 2005-07-12 15:53:39
|
Jim Morcombe wrote: > Yes, I have a LINKAGE SECTION with a number of variables. > ... > 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 OK, I think I mis-read the error messege. It is the link step that is trying to create an executable, but does not find a main entry point as declared in crt1.o. So there must be some thing wrong with the GCC link step. Looking at 'test.code/t33', the compile and link should look some thing like the following. Example: htcobol -c -P subrots.cob gcc -shared -Wl,-soname,libsubrot2.so.1.0 -o libsubrot2.so.1.0 subrots.o ln -s libsubrot2.so.1.0 libsubrot2.so ln -s libsubrot2.so.1.0 libsubrot2.so.1 |
|
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. |
|
From: Jim M. <ro...@vi...> - 2005-07-13 04:44:20
|
David My appologies. I was compiling my "called program" with the wrong script and was still trying to compile it to an executable, not a shared library. Naturally it complained. In fact, it compiles nicely. Jim |