Forum Stats

  • 3,872,169 Users
  • 2,266,401 Discussions
  • 7,911,086 Comments

Discussions

C++Builder6.0 Link Error

561922
561922 Member Posts: 13
edited Aug 22, 2007 12:20PM in Berkeley DB
Hill.
The Kerbeley DB Version is 4.0.5.20
The OS is Microsoft XP Professional Service Pack 2
Development Tool is Borland C++Builder 6.0

Source code:
------------------------------------------------------------------------------
#include <iostream.h>
#include "db_cxx.h"
using namespace std;
int main(int argc, char *argv[])
{
Db db(NULL, 0);
//std::cout << "Hello!" << std::endl;
db.close(0);
return 0;
}

------------------------------------------------------------------------------
The following error happed when program is linked.

[Linker Error] Unresolved external 'Db::~Db()' referenced from F:\OWNERDB\EEEE.OBJ
[Linker Error] Unresolved external 'Db::Db(DbEnv *, unsigned int)' referenced from F:\OWNERDB\EEEE.OBJ

TIA.
Peter

Message was edited by:
user558919
«1

Comments

  • 526060
    526060 Member Posts: 386
    Hi Peter,

    How are you building and/or installing Berkeley DB 4.5.20? This will impact exactly what steps you need to take.

    I am not familiar with Borland C++ Builder 6.0, but you will need to specify the db library file to link against in the build configuration. You will likely want to link against libdb45.lib (adding this to a "dependent libraries" setting might resolve the problem).

    Regards,
    Alex
  • 561922
    561922 Member Posts: 13
    Hi Alex,

    I'm building Berkeley DB 4.5.20 with Visual C++ .NET 2005, everything is ok, I've got a directory which name is "RELEASE". I've copied correlative files(db.h,db_cxx.h,libdb45.dll,libdb45.lib) to my project directory, and added the libdb45.lib in my project, builded, then got the following error:
    --------------------------------------------------------------------
    [Linker Error] 'F:\OWNERDB\LIBDB45.LIB' contains invalid OMF record, type 0x21 (possibly COFF)
    --------------------------------------------------------------------

    First, I think the original file(libdb45.lib, 164KB) has pitfalls, I used implib.exe(Borland Tool) to export a new library file(libdb45.lib, 93KB) through the DLL file(libdb45.dll), like this: implib libdb45.lib libdb45.dll. Then builded, and got some different errors:
    --------------------------------------------------------------------
    [Linker Error] Unresolved external 'Db::~Db()' referenced from F:\OWNERDB\EEEE.OBJ
    [Linker Error] Unresolved external 'Db::Db(DbEnv *, unsigned int)' referenced from

    F:\OWNERDB\EEEE.OBJ
    --------------------------------------------------------------------
  • 561922
    561922 Member Posts: 13
    Hi Alex,

    I'm on-line waiting for your reply, Thanks In Advance.

    Peter.
  • 526060
    526060 Member Posts: 386
    Hi,

    I just did a bit more digging, and we don't have a supported path for using the Berkeley DB library with Borland C++ on Windows.

    I don't have Borland C++ installed, so cannot test easily.

    I would suggest trying using the C interface to Berkeley DB, instead of the C++ interface. It seems likely that the missing constructor/destructor are a result of incompatible C++ name munging in the lib file.

    Try a sample application like:
    #include <iostream.h>
    #include "db.h"
    using namespace std;
    int main(int argc, char *argv[])
    {
    DB *dbp;
    int ret;
    char *database;

    database = "test.db";
    /* Create and initialize database object, open the database. */
    if ((ret = db_create(&dbp, NULL, 0)) != 0) {
    fprintf(stderr, "db_create: %s\n", db_strerror(ret));
    return (EXIT_FAILURE);
    }
    dbp->set_errfile(dbp, stderr);
    if ((ret = dbp->open(dbp,
    NULL, database, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) {
    dbp->err(dbp, ret, "%s: open", database);
    goto err1;
    }
    return 0;
    }
  • 567611
    567611 Member Posts: 10
    Hi, Peter

    Borland use OMF as a library format, so won't link with COFF libraries. There is a conversion tool (see Coff2Omf.exe in the Borland help), which didn't work for me - I had to build my Berkely DB libraries as a Borland project. I have a CBuilder 6 project for building a static lib for 4.4.16 - let me know if you need it.

    Tony
  • 561922
    561922 Member Posts: 13
    Hi, Tony

    coff2omf.exe libdb45.lib libdb45bcb.lib
    I did it like you say, but I still got same errors.

    [Linker Error] Unresolved external 'Db::~Db()' referenced from F:\OWNERDB\EEEE.OBJ

    some people tell me:
    The coff2omf.exe utility converts an import library for a DLL into a
    format usable by the linker. It does not convert a static library, a
    library containing object files. You cannot use object files created
    in the Microsoft format.

    Peter
  • 561922
    561922 Member Posts: 13
    Hi, Tony

    Please give me a static lib, dll file and header files. Do you have a MSN accounts? My MSN accounts is [email protected], Expecting...

    By the way, I want to know how do you build/install this static lib file.

    Thanks a lot!
    Peter.
  • 567611
    567611 Member Posts: 10
    Hi, Peter

    I agree. That is why I compiled my own Berkely 4.4.16 static library for Borland CBuilder 6. If you would like a copy of the Borland project file, give me an email address and I will send it to you.

    Regards,

    Tony
  • 561922
    561922 Member Posts: 13
    Hi, Tony

    I builded the lib file with C++.net 2005,coff2omf is not useful. because:

    quote from: http://www.fship.com/faq_vfs.html
    -----------------------------------------
    Q: Can I use Borland BCC with Microsoft MS-VC6++ libraries (and with FlagShip port for MS-VC6++) ?
    A: You cannot. Both Microsoft and Borland use different, incompatible object format (COFF vs. OMF). Unfortunately the Borland's converter IMPLIB and COFF2OMF does not work here, since it does not handle C++ modules used in the GUI. But there are ports of Visual FlagShip available for both platforms.
    ----------------------------------------
    And you can see:
    http://www.digitalmars.com/ctg/coff2omf.html

    It's make me puzzle! SOS!!!

    Peter.
  • 561922
    561922 Member Posts: 13
    Hi, Tony.

    My email is [email protected]
    How do you compile your Berkely 4.4.16 static library with Borland CBuilder 6?

    Thanks a lot!

    Peter.
This discussion has been closed.