Freeze sample build error

in Help Center
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)" ([email protected][email protected]@[email protected]@V[email protected]@[email protected]@[email protected]@[email protected]@Z)
Debug/myfreeze.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
myfreeze.exe - 2 error(s), 0 warning(s)
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)" ([email protected][email protected]@[email protected]@V[email protected]@[email protected]@[email protected]@[email protected]@Z)
Debug/myfreeze.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
myfreeze.exe - 2 error(s), 0 warning(s)
0
Comments
Cheers,
Bernard
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.
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
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?
[
nv "db": db: No such file or directory ]
[
nv "db": db\log.0000000001: No such file or directory ]
[
nv "db": PANIC: No such file or directory ]
[
nv "db": PANIC: DB_RUNRECOVERY: Fatal error, run database recovery ]
[
nv "db": db: No such file or directory ]
Cheers,
Bernard
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!!
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