Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intallation fails on Ubuntu #36

Open
yutaro-sakamoto opened this issue Feb 16, 2022 · 3 comments
Open

Intallation fails on Ubuntu #36

yutaro-sakamoto opened this issue Feb 16, 2022 · 3 comments
Labels

Comments

@yutaro-sakamoto
Copy link
Contributor

A sample program INSERTTBL in sample/ directory does not work on Ubuntu.

$ ocesql INSERTTBL.cbl INSERTTBL.cob
$ cobc -m -locesql INSERTTBL.cob
$ cobcrun INSERTTBL
*** INSERTTBL STARTED ***
libcob: Cannot find module 'OCESQLConnect'

In order to execute INSERTTBL, it is necessary to set the environment variable LD_PRELOAD to /usr/local/lib/libocesql.so

$ ocesql INSERTTBL.cbl INSERTTBL.cob
$ cobc -m -locesql INSERTTBL.cob
$ LD_PRELOAD=/usr/local/lib/libocesql.so cobcrun INSERTTBL

This problem is probably caused by an incorrect configuration of libocesql.so
The following Dockerfile describes the full installation process on Ubuntu.

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update

RUN apt-get install -y build-essential libncurses5 libncurses5-dev libgmp-dev bison flex gettext automake autoconf git
RUN apt-get install -y libpq-dev

RUN cd /root && git clone https://github.com/opensourcecobol/opensource-cobol.git

RUN cd /root/opensource-cobol/vbisam &&\
    ./configure --prefix=/usr/ &&\
    make &&\
    make install &&\
    cd ../ &&\
    ./configure --prefix=/usr/ --with-vbisam &&\
    make &&\
    make install

ADD https://github.com/opensourcecobol/Open-COBOL-ESQL/archive/refs/tags/v1.2.tar.gz /root/Open-COBOL-ESQL-1.2.tar.gz
RUN cd /root &&\
    tar zxvf Open-COBOL-ESQL-1.2.tar.gz &&\
    cd Open-COBOL-ESQL-1.2 &&\
    ./configure &&\
    C_INCLUDE_PATH=/usr/include/postgresql/ make &&\
    make install

RUN cd /root/Open-COBOL-ESQL-1.2/sample &&\
    cp ../copy/* . &&\
    ocesql INSERTTBL.cbl INSERTTBL.cob &&\
    cobc -m -locesql INSERTTBL.cob  &&\
    LD_PRELOAD=/usr/local/lib/libocesql.so cobcrun INSERTTBL

ENTRYPOINT ["/bin/bash"]
yutaro-sakamoto added a commit that referenced this issue Mar 9, 2022
In order to avoid the problem described in #36, A note is added to README.
@yutaro-sakamoto
Copy link
Contributor Author

It seems difficult to solve this issue.
I added note to README.

@GitMensch
Copy link
Contributor

GitMensch commented Mar 18, 2022

LD_PRELOAD is a quite bad hack, with that README note people will likely export it which commonly breaks something and tells the dynamic link loader to do this for every executable. The issue is that libcob does not find the module, very likely because the actual CALL is a dynamic one and/or the dynamic linker removed the "unused" library.

To work around this each of the following solutions should work;

  • let ocesql generate the CALLs as CALL STATIC 'OCESQLConnect' ... (cobc will directly insert the library call, the dynamic linker will resolve that from libocesql
  • let cobc generate all calls to literals as static itself - same effect cobc -static -m ...
  • tell the linker to not drop the "unused" library, by passing -Wl,--no-as-needed (depending on the cobc used that can be passed via -Q or by overriding cobc's linker call via environment variables)

... or: use COB_PRE_LOAD to load the library, or relink libcob/cobcrun to have the library linked with the -Wl,--no-as-needed option.

@yutaro-sakamoto
Copy link
Contributor Author

I removed the description of LD_PRELOAD in README and created a new wiki page for Ubuntu users.
I will fix this issue in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants