Menu

Textbook example segfaults.

Anonymous
2020-07-01
2020-07-01
  • Anonymous

    Anonymous - 2020-07-01

    I'm running Manjaro Linux (an Arch derivative) on a Raspberry Pi 4B.

    I downloaded GnuCOBOL (can you remove the way-too-many references to OpenCOBOL?).
    Compiled and installed it. ./configure, make, make install.

    Entered the hello.cob program:
    * HELLO.COB Gnu COBOL FAQ example
    IDENTIFICATION DIVISION.
    PROGRAM-ID. hello.
    PROCEDURE DIVISION.
    DISPLAY "Hello, world".
    STOP RUN.

    [ted@jamie gnucobol-3.1-rc1]$ cobc hello.cob [No diagnostics; produced hello.so]
    [ted@jamie gnucobol-3.1-rc1]$ ./hello.so
    Segmentation fault (core dumped)
    [ted@jamie gnucobol-3.1-rc1]$
    Hmm... a little poking around:
    [ted@jamie gnucobol-3.1-rc1]$ file hello.so
    hello.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=18ce78df3384de536b65c7ab127dbfa0855282e2, not stripped
    [ted@jamie gnucobol-3.1-rc1]$

     
    • Simon Sobisch

      Simon Sobisch - 2020-07-01

      You cannot directly run a shared object (so).

      Either produce an executable with cobc -x hello.cob (resulting in a callable ./hello) or, what I'd always suggest use the GnuCOBOL module runner with your current so:

      cobcrun hello.

       
    • Vincent (Bryan) Coen

      Couple of things come to mind :

      1.  Did you build and test the compiler under the Pi ?

      Assuming you have.

      Recompile  hello.cob   by running :

      cobc -x -free hello.cob

      ./hello

      Does it now work ?

      Notes :   the '-free' is needed if the program source is not a fixed
      format or you have not included the source code line  that starts in
      cc8  of :.

      >>SOURCE FREE

      and yes it can be lower case.

      Now you commented on to-many-references to OpenCOBOL

      Where are these shown as it should not be mentioned in the GC manuals :
      Programmers Guide, Sample Programs, Quick Reference ?

      There is a wee problem in that the sourceforge site was being used for
      when the compiler was called OpenCobol and we have not change the name
      of it and YES we should at least have a link to the new name and
      content.   @Simon ?

      Vince

       

      Last edit: Simon Sobisch 2020-07-01
      • Simon Sobisch

        Simon Sobisch - 2020-07-01

        There is a wee problem in that the sourceforge site was being used for when the compiler was called OpenCobol and we have not change the name of it and YES we should at least have a link to the new name and content.

        You may ask SF via its support tickets for a possible forward, this would be useful.
        The last time that I checked there was only an option to permanently change the project name - which will break any link and any svn checkout directly, which is obviously a very bad thing - or setup a forward noteto a completely different page.
        A symlink would be best. It is possible to set this up for me in the file releases [I did so to support both the old gnu-cobol and gnucobol directory for example] and it should theoretically be possible for the SF staff to also do this on the project level - but it definitely isn't for me as an admin of this SF project.

         
  • Anonymous

    Anonymous - 2020-07-01

    cobcrun worked!
    Thank you!

    However:
    cobc -x hello.cob did indeed give an executable load module, hello.
    ./hello
    ./hello: error while loading shared libraries: libcob.so.4: cannot open shared object file: No such file or directory
    It seems that make install should put the libraries where they should be: /usr/local/lib
    Sorry 'bout that. That's where they are.
    How do I get the program to pick up the libraries?

     
    • Vincent (Bryan) Coen

      I am assuming you are running under Linux so you need to tell the system
      where the cobol libraries are so to do that :

      Create a file in /etc/ld.so.conf.d

      called what ever you want but I suggest

      gnu-cobol.conf

      and in that create the following lines :

      ::text
      /usr/local/lib/gnu-cobol
      /usr/local/lib
      /usr/local/mysql/lib
      /usr/lib
      

      You can omit the line with mysql if you will never use the mysql rdbms
      service.

      As I run a x64 system I could also add
      /usr/lib64

      but for some reason I don't so you can or not

      One you have done this now run sudo ldconfig

      Remember to rerun ldconfig when ever you install a later version of the
      compiler but must admit I some times forget and I have not noticed a
      problem ---  yet :)
      .
      Now rerun ./hello and check that it now works.

      There are some other environment settings you can do (ok, I have) under
      my user id  and these are in the file ./.bashrc_profile

      Here is what I have and I have removed one's you will not want or
      require but ignore the lines with ---   ditto lines with <<< which is my
      notes to you >>>

      cat ~/.bashrc
      
      ::sh
      # .bashrc
      
      # User specific aliases and functions
      
      # Source global definitions
      if [ -f /etc/bashrc ]; then
               . /etc/bashrc
      fi
      
      # << the above should be present already or similar >>
      
      export COB_SET_TRACE=YES
      export COB_TRACE_FILE=${HOME}/trace.log    # <<  these 2 only if you want to do tracingof your programs when testing >>
      export COB_SCREEN_ESC=YES
      export COB_SCREEN_EXCEPTIONS=YES
      export COB_LIBRARY_PATH=~/bin               # <<   this is my user directory for programs >>
      #
      export PATH=PATH;~/bin                              # << and here too >>
      export TMPDIR=~/tmp                 # <<<<   You might want this one or as ~/tmp
      

      That should keep you going

      Vince

       

      Last edit: Simon Sobisch 2020-07-01
    • Simon Sobisch

      Simon Sobisch - 2020-07-01

      Most systems don't auto-load from /usr/local/lib.
      You may want to add it to LD_LIBRARY_PATH, for example in the profile or bahsrc.

       

Anonymous
Anonymous

Add attachments
Cancel