paxmanchris
January 2nd, 2007, 09:27 PM
i have been going crazy trying to get OpenCobol to work with ubuntu.
i have check an old thread (http://www.ubuntuforums.org/showthread.php?t=115617&highlight=opencobol) for this, but it did not offer any help that i can use.
i got to the point of getting cobc to on my computer useing:
sudo apt-get install open-cobol
i made a test.cob file with the contents of:
IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.
then i ran this command:
~$ cobc test.cob
it is able to genrate the c code, BUT it is unable to compile the c code into a binary.
the following is the genrated c code:
--hello.c--
/* Generated from test.cob by cobc 0.32 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <libcob.h>
#include "hello.h"
static int hello_ (int);
int
hello ()
{
return hello_ (0);
}
static int
hello_ (int entry)
{
static int initialized = 0;
static cob_module module = { NULL, NULL, 0, '.', '$', ',', 0, 1, 1};
cob_field f[4];
/* perform frame stack */
int frame_index;
struct frame { int perform_through; void *return_address; } frame_stack[254];
/* Start of function code */
cob_module_enter (&module);
if ( __builtin_expect(!initialized, 0) )
{
(*(int *) (b_2)) = 0;
(*(int *) (b_3)) = 0;
cob_move (&cob_zero, (f[1] = (cob_field) {4, b_4, &a_7}, &f[1]));
initialized = 1;
}
/* initialize frame stack */
frame_index = -1;
frame_stack[0].perform_through = -1;
/* initialize number of call params */
(*(int *) (b_3)) = cob_call_params;
goto l_6;
/* PROCEDURE DIVISION */
/* hello: */
l_6:;
/* test.cob:4: DISPLAY */
{
cob_display (&c_9);
cob_newline ();
}
/* test.cob:5: STOP */
{
cob_stop_run ((*(int *) (b_2)));
}
cob_module_leave (&module);
return (*(int *) (b_2));
/* error handlers */
/* standard_error_handler: */
l_1:;
switch (cob_error_file->last_open_mode)
{
default:
if ( !cob_error_file->flag_has_status ) {
cob_default_error_handle ();
exit(1);
}
break;
}
if (frame_stack[frame_index].perform_through == 1)
goto *frame_stack[frame_index].return_address;
fprintf(stderr, "Codegen error\n");
exit(1);
}
and the header
--hello.h--
static unsigned char b_2[4] __attribute__ ((__aligned__(8))); /* RETURN-CODE */
static unsigned char b_3[4] __attribute__ ((__aligned__(8))); /* NUMBER-OF-CALL-PARAMETERS */
static unsigned char b_4[4] __attribute__ ((__aligned__(8))); /* TALLY */
static cob_field_attr a_8 = {33, 0, 0, 0, 0};
static cob_field_attr a_7 = {17, 9, 0, 0, 0};
static cob_field c_9 = {12, "Hello World!", &a_8};
and finally the errors:
/tmp/cobRWiPIF.c:3:19: error: stdio.h: No such file or directory
/tmp/cobRWiPIF.c:4:20: error: stdlib.h: No such file or directory
/tmp/cobRWiPIF.c:5:20: error: string.h: No such file or directory
/tmp/cobRWiPIF.c:6:18: error: math.h: No such file or directory
In file included from /usr/include/libcob.h:23,
from /tmp/cobRWiPIF.c:7:
/usr/include/libcob/byteswap.h:28:23: error: sys/types.h: No such file or directory
In file included from /usr/include/libcob/call.h:23,
from /usr/include/libcob.h:24,
from /tmp/cobRWiPIF.c:7:
/usr/include/libcob/common.h:88: error: expected specifier-qualifier-list before ‘size_t’
In file included from /usr/include/libcob.h:26,
from /tmp/cobRWiPIF.c:7:
/usr/include/libcob/fileio.h:127: error: expected specifier-qualifier-list before ‘size_t’
In file included from /tmp/cobRWiPIF.c:9:
/tmp/cobRWiPIF.c.h:6: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c.h:6: warning: (near initialization for ‘c_9’)
/tmp/cobRWiPIF.c.h:6: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c.h:6: warning: (near initialization for ‘c_9’)
/tmp/cobRWiPIF.c.h:6: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c.h:6: warning: (near initialization for ‘c_9’)
/tmp/cobRWiPIF.c: In function ‘hello_’:
/tmp/cobRWiPIF.c:32: error: ‘NULL’ undeclared (first use in this function)
/tmp/cobRWiPIF.c:32: error: (Each undeclared identifier is reported only once
/tmp/cobRWiPIF.c:32: error: for each function it appears in.)
/tmp/cobRWiPIF.c:52: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c:52: warning: (near initialization for ‘(anonymous)’)
/tmp/cobRWiPIF.c:52: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c:52: warning: (near initialization for ‘(anonymous)’)
/tmp/cobRWiPIF.c:52: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c:52: warning: (near initialization for ‘(anonymous)’)
/tmp/cobRWiPIF.c:84: error: ‘cob_file’ has no member named ‘last_open_mode’
/tmp/cobRWiPIF.c:87: error: ‘cob_file’ has no member named ‘flag_has_status’
/tmp/cobRWiPIF.c:89: warning: incompatible implicit declaration of built-in function ‘exit’
/tmp/cobRWiPIF.c:95: warning: incompatible implicit declaration of built-in function ‘fprintf’
/tmp/cobRWiPIF.c:95: error: ‘stderr’ undeclared (first use in this function)
/tmp/cobRWiPIF.c:96: warning: incompatible implicit declaration of built-in function ‘exit’
i really hope that someone can help me here. i need this for one my classes and i DONT want to use window.
oh.. if you know of a GOOD cobol complier for window (one which is free). let me know.
i have check an old thread (http://www.ubuntuforums.org/showthread.php?t=115617&highlight=opencobol) for this, but it did not offer any help that i can use.
i got to the point of getting cobc to on my computer useing:
sudo apt-get install open-cobol
i made a test.cob file with the contents of:
IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.
then i ran this command:
~$ cobc test.cob
it is able to genrate the c code, BUT it is unable to compile the c code into a binary.
the following is the genrated c code:
--hello.c--
/* Generated from test.cob by cobc 0.32 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <libcob.h>
#include "hello.h"
static int hello_ (int);
int
hello ()
{
return hello_ (0);
}
static int
hello_ (int entry)
{
static int initialized = 0;
static cob_module module = { NULL, NULL, 0, '.', '$', ',', 0, 1, 1};
cob_field f[4];
/* perform frame stack */
int frame_index;
struct frame { int perform_through; void *return_address; } frame_stack[254];
/* Start of function code */
cob_module_enter (&module);
if ( __builtin_expect(!initialized, 0) )
{
(*(int *) (b_2)) = 0;
(*(int *) (b_3)) = 0;
cob_move (&cob_zero, (f[1] = (cob_field) {4, b_4, &a_7}, &f[1]));
initialized = 1;
}
/* initialize frame stack */
frame_index = -1;
frame_stack[0].perform_through = -1;
/* initialize number of call params */
(*(int *) (b_3)) = cob_call_params;
goto l_6;
/* PROCEDURE DIVISION */
/* hello: */
l_6:;
/* test.cob:4: DISPLAY */
{
cob_display (&c_9);
cob_newline ();
}
/* test.cob:5: STOP */
{
cob_stop_run ((*(int *) (b_2)));
}
cob_module_leave (&module);
return (*(int *) (b_2));
/* error handlers */
/* standard_error_handler: */
l_1:;
switch (cob_error_file->last_open_mode)
{
default:
if ( !cob_error_file->flag_has_status ) {
cob_default_error_handle ();
exit(1);
}
break;
}
if (frame_stack[frame_index].perform_through == 1)
goto *frame_stack[frame_index].return_address;
fprintf(stderr, "Codegen error\n");
exit(1);
}
and the header
--hello.h--
static unsigned char b_2[4] __attribute__ ((__aligned__(8))); /* RETURN-CODE */
static unsigned char b_3[4] __attribute__ ((__aligned__(8))); /* NUMBER-OF-CALL-PARAMETERS */
static unsigned char b_4[4] __attribute__ ((__aligned__(8))); /* TALLY */
static cob_field_attr a_8 = {33, 0, 0, 0, 0};
static cob_field_attr a_7 = {17, 9, 0, 0, 0};
static cob_field c_9 = {12, "Hello World!", &a_8};
and finally the errors:
/tmp/cobRWiPIF.c:3:19: error: stdio.h: No such file or directory
/tmp/cobRWiPIF.c:4:20: error: stdlib.h: No such file or directory
/tmp/cobRWiPIF.c:5:20: error: string.h: No such file or directory
/tmp/cobRWiPIF.c:6:18: error: math.h: No such file or directory
In file included from /usr/include/libcob.h:23,
from /tmp/cobRWiPIF.c:7:
/usr/include/libcob/byteswap.h:28:23: error: sys/types.h: No such file or directory
In file included from /usr/include/libcob/call.h:23,
from /usr/include/libcob.h:24,
from /tmp/cobRWiPIF.c:7:
/usr/include/libcob/common.h:88: error: expected specifier-qualifier-list before ‘size_t’
In file included from /usr/include/libcob.h:26,
from /tmp/cobRWiPIF.c:7:
/usr/include/libcob/fileio.h:127: error: expected specifier-qualifier-list before ‘size_t’
In file included from /tmp/cobRWiPIF.c:9:
/tmp/cobRWiPIF.c.h:6: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c.h:6: warning: (near initialization for ‘c_9’)
/tmp/cobRWiPIF.c.h:6: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c.h:6: warning: (near initialization for ‘c_9’)
/tmp/cobRWiPIF.c.h:6: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c.h:6: warning: (near initialization for ‘c_9’)
/tmp/cobRWiPIF.c: In function ‘hello_’:
/tmp/cobRWiPIF.c:32: error: ‘NULL’ undeclared (first use in this function)
/tmp/cobRWiPIF.c:32: error: (Each undeclared identifier is reported only once
/tmp/cobRWiPIF.c:32: error: for each function it appears in.)
/tmp/cobRWiPIF.c:52: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c:52: warning: (near initialization for ‘(anonymous)’)
/tmp/cobRWiPIF.c:52: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c:52: warning: (near initialization for ‘(anonymous)’)
/tmp/cobRWiPIF.c:52: warning: excess elements in struct initializer
/tmp/cobRWiPIF.c:52: warning: (near initialization for ‘(anonymous)’)
/tmp/cobRWiPIF.c:84: error: ‘cob_file’ has no member named ‘last_open_mode’
/tmp/cobRWiPIF.c:87: error: ‘cob_file’ has no member named ‘flag_has_status’
/tmp/cobRWiPIF.c:89: warning: incompatible implicit declaration of built-in function ‘exit’
/tmp/cobRWiPIF.c:95: warning: incompatible implicit declaration of built-in function ‘fprintf’
/tmp/cobRWiPIF.c:95: error: ‘stderr’ undeclared (first use in this function)
/tmp/cobRWiPIF.c:96: warning: incompatible implicit declaration of built-in function ‘exit’
i really hope that someone can help me here. i need this for one my classes and i DONT want to use window.
oh.. if you know of a GOOD cobol complier for window (one which is free). let me know.