Menu

Can't link libcob.so.4

Anonymous
2017-01-06
2018-10-04
  • Anonymous

    Anonymous - 2017-01-06

    I just downloaded and did a vanilla install of 2.0 on a CentOS-7 system. I am able to get an executable just fine but when I run it, it says libcob.so.4 can't be found. It is sitting, as a link, in /usr/local/lib.

    $ ls -la /usr/local/lib
    ...
    lrwxrwxrwx. 1 root root 15 Jan 5 15:03 libcob.so.4 -> libcob.so.4.0.0

    The gcc command line from cobc -v is:

    gcc -std=gnu99 -Wl,--export-dynamic -o "first"
    "/tmp/cob15958_0.o" -L/usr/local/lib -lcob -lm -lgmp
    -lncursesw -ldb -ldl

    ldd says:
    ldd first
    linux-vdso.so.1 => (0x00007ffe90c7a000)
    libcob.so.4 => not found
    libm.so.6 => /lib64/libm.so.6 (0x00007fa18113c000)
    ...

    and of course, running it gives:
    ./first
    ./first: error while loading shared libraries: libcob.so.4: cannot open shared object file: No such file or directory

    I'm not trying to do anything fancy. 'just a simple "hello world" program.

    Thanks

     
    • Simon Sobisch

      Simon Sobisch - 2017-01-06

      Hello Anonymous,

      you use a 64bit system which doesn't have /usr/local/lib in the standard search paths but installed GnuCOBOL there. As cobc knows about the installation path it adds it to the linker paths, allowing the link to finish as you've shown above.

      A completely different issue is the running (the part where lddgets its lookup paths from).
      Either use export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH or if you have 32bit libraries with the sane names there the other way around export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib or create a symlink to libcob.so.4 from /usr/local/lib to /usr/local/lib64 (if you have it and it is in your lookup path).

      Another option is to add -Wl,-R/usr/local/lib to COB_LDFLAGS leading to an "hard burned in" lookup path, which will always be searched by the environment when resolving the executable/shared object produced by cobc. If you want to go this route it is likely a good idea to reconfigure and reinstall for placing it in the defaults for COB_LDFLAGS.

      Simon

       
  • Anonymous

    Anonymous - 2017-01-06

    The export LD_LIBRARY_PATH did it. Thanks!

     
  • Anonymous

    Anonymous - 2018-10-04

    thanks,

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.