Menu

Berkeley DB db.h is missing

2015-10-22
2020-04-18
  • Paul Richards

    Paul Richards - 2015-10-22

    I borked my Ubuntu installation and am having to reinstall everything. I installed Berkeley DB - it's in /usr/local/BerkeleyDB6.1 and db.h is in the include directory

    Downloaded GnuCOBOL 2.0 and ./configure gives 'configure: error: BerkeleyDB db.h is missing'

    I hope there's a simple way to overcome this issue :-)

    Paul

     
    • Simon Sobisch

      Simon Sobisch - 2015-10-22

      I hope there's a simple way to overcome this issue :-)

      Sure.

      ::bash
      ./configure LDFLAGS=-L/usr/local/BerkeleyDB6.1 CPPFLAGS=-I/usr/local/BerkeleyDB6.1/include
      

      or, if you actually don't need ISAM better use

      ::bash
      ./configure --without-db
      

      (better because of license issues with Oracles Berkeley DB)

      Simon

       
    • Vincent (Bryan) Coen

      On my system I have:

      /usr/include/db.h
      /usr/include/db53
      /usr/include/db53/db.h
      /usr/include/db53/db_185.h
      /usr/include/db53/db_cxx.h
      /usr/include/db53/dbsql.h

      and

      /usr/lib64/libdb-5.3.la
      /usr/lib64/libdb-5.so
      /usr/lib64/libdb.so
      /usr/lib64/libdb_cxx-5.3.la
      ............... more .....

      So I recommend you do :

      sudo ln -s /usr/local/BerkeleyDB6.1 /usr/include/

      You need to see (ls -la ) what is in the /usr/local/BerkeleyDB6.1
      directory FIRST

      If the content is the include directory then change the above ln to

      sudo ln -s /usr/local/BerkeleyDB6.1/include /usr/include/

      Now if also in the directory is the lib64 directory (assuming you are
      running X64 Linux otherwise lib directory so

      sudo ln -s /usr/local/BerkeleyDB6.1/lib64 (or lib) /usr/lib64 (or lib)

      Now when running the ./configure for the compiler it should all work and
      any compiles that require the isam package will all work.

      Do not forget (as assuming you created a file in the /etc/ld.so.conf.d
      of say gnu-cobol.conf as I suggested in a previous message run
      sudo ldconfig

      do this after building the compiler and running sudo make install

      Failure not to do so will mean the system will NOT find the gnu Cobol
      libraries and with it the DB ones.

      .
      Vince

      On 22/10/15 12:27, Paul Richards wrote:

      I borked my Ubuntu installation and am having to reinstall everything.
      I installed Berkeley DB - it's in /usr/local/BerkeleyDB6.1 and db.h is
      in the include directory

      Downloaded GnuCOBOL 2.0 and ./configure gives 'configure: error:
      BerkeleyDB db.h is missing'

      I hope there's a simple way to overcome this issue :-)

      Paul


       
  • Paul Richards

    Paul Richards - 2015-10-22

    Vince: thanks for you help.

    I tried sudo ln -s /usr/local/BerkeleyDB6.1 /usr/include/ and sudo ln -s /usr/local/BerkeleyDB6.1/include /usr/include/ - both came up with same error as before i.e.db.h is missing

    I tried ./configure LDFLAGS=-L/usr/local/BerkeleyDB6.1 CPPFLAGS=-I/usr/local/BerkeleyDB6.1/include. This found the db.h then checked for DB library version 6.1 but came up with 'BDB library version 6.1 not found'

    In the BDB lib sub-directory there is libdb-6.1.la, libdb-6.1.so and libdb-6.so. I'm hoping there just needs to be another flag in configure pointing to the lib directory.

    Your expert advice is needed again :-)

    Thanks

     

    Last edit: Paul Richards 2015-10-22
    • Simon Sobisch

      Simon Sobisch - 2015-10-23

      As you did not gave the information wit lib subdirectory before the configure line was wrong. Use ./configure LDFLAGS=-L/usr/local/BerkeleyDB6.1/lib CPPFLAGS=-I/usr/local/BerkeleyDB6.1/include instead.

      I did told you about --without-db, didn't I?

      Simon

       
      • Paul Richards

        Paul Richards - 2015-10-23

        Simon:

        I did told you about --without-db, didn't I?<

        Yes, but I want ISAM with COBOL - I thought Berkeley DB was a requirement with GnuCOBOL and ISAM.

        Running ./configure LDFLAGS=-L/usr/local/BerkeleyDB6.1/lib CPPFLAGS=-I/usr/local/BerkeleyDB6.1/include still gives 'BDB library version 6.1 not found'

        Paul

         
        • Simon Sobisch

          Simon Sobisch - 2015-10-23

          This is what configure does:

          • extract BDB version information from db.h (version major + . + minor) and display it as version "V" (in your case 6.1)
          • link against -ldb-V, in your case -ldb-6.1 (which tells the linker to search for libdb-6.1.a [static] and if it's not there link against libdb-6.1.la [dynamic, needs libdb-6.1.so on runtime]), with LDFLAGS=-L you tell the linker where to look - should work (if you have the correct architecture 32/64bit issue).

          I suggest you upload your config.log as this may show a little bit more.

          Simon

           
          • Paul Richards

            Paul Richards - 2015-10-23

            Simon: config.log attached.

            I don't know why there is such a problem. BDB installed fine and so did GnuCOBOL before I borked my installation..

             

            Last edit: Paul Richards 2015-10-24
            • Simon Sobisch

              Simon Sobisch - 2015-10-24

              To solve this issue - this is what would have worked:

              export LD_LIBRARY_PATH=/usr/local/BerkeleyDB.6.1/lib:$LD_LIBRARY_PATH
              ./configure LDFLAGS=-L/usr/local/BerkeleyDB.6.1/lib CPPFLAGS=-I/usr/local/BerkeleyDB.6.1/include
              

              config.log shows that linking worked, but running failed:

              error while loading shared libraries: libdb-6.1.so: cannot open shared object file: No such file or directory

              For permanent setting of LD_LIBRARY_PATH (as you would need to set it before using cobc/cobcrun/libcob once per session) you could add the setting to /etc/ld.so.conf.d/.conf. CPPFLAGS and LDFLAGS passed to configure are not needed to set any more (as they get hardwired in your build of GnuCOBOL on this machine - overridable via environment).

               
    • Brian Tiffin

      Brian Tiffin - 2015-10-23

      Paul; symlinking dirs is not going to usually do what you think. You need to symlink individual files in that case.

      For libraries, you can temporarily set LD_LIBRARY_PATH or dig in and play with ldconfig. In ld.so.conf.d, just add a myname.conf (call it anything, ending in .conf) that names the directory where the .so files are. Then run sudo ldconfig.

      But, there is a catch. There are two kinds of shared libraries in GNU/Linux. Shared libraries and Dynamic Shared Object libraries. Dynamic Shared Objects are versioned in terms of the link loader cache. That's why you'll see things like libc.so libc.so.6 and libc.so.6.1, with the versioned files actually symlinked to the main file, usually libc.so.6.1 sym'ed to libc.so.6 and libc.so.6 sym;ed to libc.so. This complicating headache actually has benefits that allow Unix systems to be upgraded while running, a feature most of us can take for granted. Until you can't, then it's a headache. ;-)

      Usually the easiest way around install issues is to lean to the package maintainers. They know the voodoo required, so if you can, look into the Ubuntu repositories for the latest BDB listed, or to be honsest, pretty much any version if the goal is GnuCOBOL 2, and install it, along with the -dev package. Post install hooks will take care of the versioning and sym linking, and you can get on with areas of interest without getting too bogged down, until absolutely necessary.

      I'd only want to take on configuring a system to use local installed libraries if that's the only option, and there is no binary package to rely on. The maintainers can keep all the voodoo to themselves, and we can keep on keeping on, without getting dragged into a (fairly heavy, wide and deep) knowledge base.

      But if you need BDB6.1, then look to adding a .conf file in /etc/ld.so.conf.d and perhaps manually creating a libdb.so.6 and libdb.so.6.1 that are symlinked (within those dirs, not to system space, let ldconfig .conf worry about that). But again, knowing what is correct may take some deep reading through the Berkeley docs, and/or looking through other (repository) source packages (not source code, the source of an installer package) for hints on how the layout is usually setup.

      All that advice changes if an area of interest is system administration, but for developers wanting to run compiles, that usually isn't the point of the exercise. It doesn't hurt, but know how in sysadmin is getting to be a very complex world, and requires a fair amount of time and attention to be proficient at the art. I prefer to leave most of that know how to others, unless faced with no alternatives, and an itch that won't go away, making it worth the hassles. For the GnuCOBOL dependencies, there are alternatives. :-)

      Brian

       
    • Vincent (Bryan) Coen

      That's the puppy - create a link using ln -s from the directory
      containing the libs to /usr/lib (64 if used).

      They really should be actually in /usr/lib (64) but ubuntu does things
      non-standard in Linux.

      Must admit I avoid using it for other than mythtv (mythtvbuntu distro)
      but only for my media computer that sits under the TV.

      Another choice is to link the library directory to the file used for GNU
      Cobol in /etc/ld.so.conf.d/gnu-cobol.conf

      That said I would do both - belts and braces job :)

      Vince

      On 22/10/15 23:47, Paul Richards wrote:

      Vince: thanks for you help.

      I tried |sudo ln -s /usr/local/BerkeleyDB6.1 /usr/include/| and |sudo
      ln -s /usr/local/BerkeleyDB6.1/include /usr/include/| - both came up
      with same error as before i.e.db.h is missing

      I tried |./configure LDFLAGS=-L/usr/local/BerkeleyDB6.1
      CPPFLAGS=-I/usr/local/BerkeleyDB6.1/include|. This found the db.h then
      checked for DB library version 6.1 but came up with 'BDB library
      version 6.1 not found'

      In the BDB lib sub-directory there is libdb-6.1.la, libdb-6.1.so and
      libdb-6.so. I'm hoping there just needs to be something else pointing
      to the lib directory.

      Your expert advice is needed again :-)

       
  • Paul Richards

    Paul Richards - 2015-10-24

    Simon

    I have solved the problem. I got BDB 5.3 and installed that version. Creating a gnu-cobol.conf as per Vince's instructions and running sudo ldconfig gives me a v2.0 of gnucobol. Now adding opencobolide.

    Many thanks to you, Vince, Brian and Bill. You saved my bacon :-)

    Paul

     
  • RJ Candler

    RJ Candler - 2016-09-15

    Hello Gents!

    I see you guys were able to get Paul up and running. I hope you can do the same for me.
    My background is mainframe, and I am trying to refresh my COBOL skills. I have spent the last 10-11 years in leadership and now brushing up to get back into the technical game. With that said, I am fairly new (limited unix/linux skills) to the distributed side of the house.

    I have attempted to follow the above dialogue to resolve my - "configure: error: Berkeley DB db.h is missing" issue.

    Thus far, I have been able to set the following parameters, but still receiving the above db.h error.

    export LD_LIBRARY_PATH=/usr/local/BerkeleyDB.6.1/lib:$LD_LIBRARY_PATH
    ./configure LDFLAGS=-L/usr/local/BerkeleyDB.6.1/lib CPPFLAGS=-I/usr/local/BerkeleyDB.6.1/include

    I dont fully understand how to create a link/alias to /etc/ld.so.conf.d/gnu-cobol.conf
    or even what this file should contain. Also, how and where would I check to see if the DB files were compiled correctly, if at all?

    Any help is much appreciated.

    Thanks!

    RJ

     
    • Vincent (Bryan) Coen

      Have you installed lib64db6.1-devel ?

      OR if you are running a 32 bit system the libdb6.1-devel

      It has the headers etc see my file list in that area (includes) but for
      v5.3


      /usr/include/db.h
      /usr/include/db53
      /usr/include/db53/db.h
      /usr/include/db53/db_185.h
      /usr/include/db53/db_cxx.h
      /usr/include/db53/dbsql.h
      /usr/lib64/libdb-5.3.la
      /usr/lib64/libdb-5.so
      /usr/lib64/libdb.so
      /usr/lib64/libdb_cxx-5.3.la
      /usr/lib64/libdb_cxx-5.so
      /usr/lib64/libdb_cxx.so
      /usr/lib64/libdb_java-5.3.la
      /usr/lib64/libdb_java-5.so
      /usr/lib64/libdb_java.so
      /usr/lib64/libdb_sql-5.3.la
      /usr/lib64/libdb_sql-5.so
      /usr/lib64/libdb_sql.so
      /usr/lib64/libdb_tcl-5.3.la
      /usr/lib64/libdb_tcl-5.so
      /usr/lib64/libdb_tcl.so


      Vince

      On 15/09/16 20:13, RJ Candler wrote:

      Hello Gents!

      I see you guys were able to get Paul up and running. I hope you can do
      the same for me.
      My background is mainframe, and I am trying to refresh my COBOL
      skills. I have spent the last 10-11 years in leadership and now
      brushing up to get back into the technical game. With that said, I am
      fairly new (limited unix/linux skills) to the distributed side of the
      house.

      I have attempted to follow the above dialogue to resolve my -
      "configure: error: Berkeley DB db.h is missing" issue.

      Thus far, I have been able to set the following parameters, but still
      receiving the above db.h error.

      export LD_LIBRARY_PATH=/usr/local/BerkeleyDB.6.1/lib:$LD_LIBRARY_PATH
      ./configure LDFLAGS=-L/usr/local/BerkeleyDB.6.1/lib
      CPPFLAGS=-I/usr/local/BerkeleyDB.6.1/include

      I dont fully understand how to create a link/alias to
      /etc/ld.so.conf.d/gnu-cobol.conf
      or even what this file should contain. Also, how and where would I
      check to see if the DB files were compiled correctly, if at all?

      Any help is much appreciated.

      Thanks!

       
    • Simon Sobisch

      Simon Sobisch - 2016-09-15

      Hello RJ and welcome to both sides of COBOL (we'll get you running shortly ;-)

      despite the hint of Vince about the devel package:
      Do you installed BDB 6.1 from source (and run the final sudo make install)?
      I assume you have checked that the files are really in the folders you've passed to configure. Do you?

       
  • RJ Candler

    RJ Candler - 2016-09-22

    Thanks for your response Simon.

    where would I check to ensure the DB files are installed. Btw, I have DB version 5.3.28.

    thanks!

     
    • Brian Tiffin

      Brian Tiffin - 2016-09-22

      Just a hint, RJ, get used to locate when using GNU/Linux. Most distros have an mlocate package. After that it'll schedule nightly updates to a database, but you can force that with sudo updatedb, (you want to be the root user when making the database updates - usually). Then just locate db.h. It's an all in search, so you might get lots of hits.

      Most common place is /usr/include for repo installs and /usr/local/include for local builds. For the actually libaries, things get a little trickier, depending on chipset, but locate libdb.so should be a good start. Or if you have a working GnuCOBOL program, ldd program will list all the library dependencies and where they are on the filesystem.

      Cheers,
      Brian

       
  • Piyush Bansal

    Piyush Bansal - 2018-05-25

    Hello everyone,
    I am a COBOL noob.
    I installed Berkeley DB 6.2. I still get Berkeley DB db.h missing error on my Ubuntu 16.04.
    I tried to use the flags as suggested by Simon but then it says that C compiler cannot create executables. I have libc6-dev already installed.

    Thanks,
    Pi

     
    • Piyush Bansal

      Piyush Bansal - 2018-05-25

      Again went over the thread and installed libdb-dev.
      Worked like a charm.

      Thank you,
      Pi

       
  • KenUnix

    KenUnix - 2019-11-03

    After years of using SourceForgeNet I think it's about time I try and help others.
    While my postings may not all be original, l I try and gather information and test it.
    My hope is to organize my information that works, in one place.

    The following lines fixed problems with both Ubuntu 18.04 under Windows 10
    and for Ubuntu Mate 19.10 standalone

    Install Berkley Data Base tools:
    sudo apt install libdb-dev

    At the end of .bashrc add the following:
    export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

    After making the above change to .bashrc logout and log back. In
    the case of Ubuntu BASH on Windows exit bash and re-run it.

    Then download, unpack and install gnucobol-3.0-rc1.tar.xz from
    https://sourceforge.net/projects/open-cobol/files/gnu-cobol/3.0/

    During 'make' I get a couple of warnings but thngs run fine. Difference
    is one machine has gcc 7..4.0 and the other has gcc 9.2.1. You can
    determine yours by using the command gcc --version

    To test enter this simple cobol program and call it avg.cbl
    Just copy it and paste it into ed

          IDENTIFICATION DIVISION.
           PROGRAM-ID. AVERAGE_THREE_NUMBERS.
           DATA DIVISION.
           WORKING-STORAGE SECTION.
               77 NUM_1 PIC 9(4).
               77 NUM_2 PIC 9(4).
               77 NUM_3 PIC 9(4).
               77 SOLVE_AVERAGE PIC 9(4).
           PROCEDURE DIVISION.
              DISPLAY "AVERAGE OF THREE NUMBERS IN COBOL".
              DISPLAY " ".
              DISPLAY "ENTER THE FIRST VALUE : ".
              ACCEPT NUM_1.
              DISPLAY "ENTER THE SECOND VALUE : ".
              ACCEPT NUM_2.
              DISPLAY "ENTER THE THIRD VALUE : ".
              ACCEPT NUM_3.
              COMPUTE SOLVE_AVERAGE = (NUM_1 + NUM_2 + NUM_3)/3.
              DISPLAY "THE AVERAGE IS " SOLVE_AVERAGE.
              STOP RUN.
    

    Then compile and test it. Type in cobc -x avg.cbl
    Then run it. Type in ./svg

    Hope this helps.

    Ken-Unix

     

    Last edit: Simon Sobisch 2019-11-03
  • Anonymous

    Anonymous - 2020-04-18

    install libdb-dev

     

Anonymous
Anonymous

Add attachments
Cancel