Archived

This forum has been archived. Please start a new discussion on GitHub.

Freeze sample build error

hello, I want to run the freeze sample in manual 21.3.5.
but I get some build error. It look like a STL error. but others sample
work fine.
have any advice to me?

// myfreeze.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"

#include "Freeze/Freeze.h"
#include "StringIntMap.h"

using namespace std;
int
main(int argc, char* argv[])
{
// Initialize the Communicator.
//
Ice::CommunicatorPtr communicator =
Ice::initialize(argc, argv);
// Create a Freeze database connection.
//
Freeze::ConnectionPtr connection =
Freeze::createConnection(communicator, "db");
// Instantiate the map.
//
StringIntMap map(connection, "simple");
// Clear the map.
//
map.clear();
Ice::Int i;
StringIntMap::iterator p;
// Populate the map.
//
for (i = 0; i < 26; i++) {
std::string key(1, 'a' + i);
map.insert(make_pair(key, i));
}
// Iterate over the map and change the values.
//
for (p = map.begin(); p != map.end(); ++p)
p.set(p->second + 1);
// Find and erase the last element.
//
p = map.find("z");
assert(p != map.end());
map.erase(p);
// Clean up.
//
connection->close();
communicator->destroy();
return 0;
}
Configuration: myfreeze - Win32 Debug
Linking...
myfreeze.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> >::basic_string<char,class _STL::char_traits<char>,class _STL::alloc
ator<char> >(int,int)" (__imp_??0?$basic_string@DV?$char_traits@D@_STL@@V?$allocator@D@2@@_STL@@QAE@HH@Z)
Debug/myfreeze.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

myfreeze.exe - 2 error(s), 0 warning(s)

Comments

  • bernard
    bernard Jupiter, FL
    If you use Visual C++ 6 with STLPort, make sure you build Berkeley DB with STLPort configured. See INSTALL.WINDOWS for details.

    Cheers,
    Bernard
  • Is this a STLPort or VC bug?(not support string construct this type)
    I find if i remove the statement: std::string key(1, 'a' + i);
    the build pass. so I change it as :
    std::string key("a");
    key[0]+= i;
    and rebuild it ok.
  • bernard
    bernard Jupiter, FL
    If you don't build Berkeley DB with STLPort, it's your build that is incorrect.

    You have to use STLPort for all C++ components in your application (in particular Ice and Berkeley DB if your compiler is VC6) ... you cannot sometimes use STLPort and sometimes use the VC6 STL library and expect everything to build/run properly.

    Cheers,
    Bernard
  • bernard,thank your reply quickly.
    but I think i had build Berkeley DB with STLPort follow the install guide and. run it STLPort lib.
    but the application run and will generate some error: what is it mean?
    if i really need to build the Berkerley DB with STLPort again?

    [ D:\OpenSource\Ice-1.5.1\demo\Ice\myfreeze\Debug\myfreeze.exe: Berkeley DB: DbE
    nv "db": db: No such file or directory ]
    [ D:\OpenSource\Ice-1.5.1\demo\Ice\myfreeze\Debug\myfreeze.exe: Berkeley DB: DbE
    nv "db": db\log.0000000001: No such file or directory ]
    [ D:\OpenSource\Ice-1.5.1\demo\Ice\myfreeze\Debug\myfreeze.exe: Berkeley DB: DbE
    nv "db": PANIC: No such file or directory ]
    [ D:\OpenSource\Ice-1.5.1\demo\Ice\myfreeze\Debug\myfreeze.exe: Berkeley DB: DbE
    nv "db": PANIC: DB_RUNRECOVERY: Fatal error, run database recovery ]
    [ D:\OpenSource\Ice-1.5.1\demo\Ice\myfreeze\Debug\myfreeze.exe: Berkeley DB: DbE
    nv "db": db: No such file or directory ]
  • bernard
    bernard Jupiter, FL
    By default, Freeze uses the environment name as the the Berkeley DB home directory (here db). You can change this using Freeze.DbEnv.env-name.DbHome. This directory must exist before you run your application.

    Cheers,
    Bernard
  • problems with Freeze.DbEnv.env-name.DbHome

    Hi Bernard,

    My problem is that I set this variable to a folder (/home/myuser/db) and also set

    Freeze::ConnectionPtr connection =
    Freeze::createConnection(communicator, "/home/myuser/db");

    and it doesn't work , the same error appears:

    [ ./test Berkeley DB: DbEnv "/home/myuser/db": DB_TXN-> Log undo failed for LSN: 1 15540: No such file or directory ]

    What I suppose is that it is not a correct folder , and I should set a correct environment folder from berkeley DB. How can I see which is my current DB environment folder? I haven't worked with Berkeley before so maybe I am misunderstanding smthing.

    Any suggestion would be appreciate,

    Thanks in advanced!!
  • bernard
    bernard Jupiter, FL
    Here, your env-name is "/home/myuser/db", so the variable name would be:
    Freeze.DbEnv./home/myuser/db.DbHome

    Assuming you don't define this property, the db home directory is going to be /home/myuser/db. This directory must exist (Freeze won't create it for you), and must be writable. It's also better to use a local directory (as opposed to NFS-mounted). And please start with a clean directory, with no old db files or log files.

    Bernard