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
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "Help getting started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
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
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
ldd
gets 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 aroundexport 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
toCOB_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 forCOB_LDFLAGS
.Simon
View and moderate all "Help getting started" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
The export LD_LIBRARY_PATH did it. Thanks!
thanks,