title: One C++ application can not open 2 SQLite databases in one thread on linux?
body: <p>I actually seem to have problem with this (only on linux, described <a href="https://stackoverflow.com/questions/8019485/invisiable-sigsegv-on-linux-that-does-not-happen-on-windows">here</a> with stacktrace like</p>
  
  <pre><code>==11682==    at 0x0: ??? // Here goes the error=(
  ==11682==    by 0x4D49BE: sqlite3_free (sqlite3.c:18155)
  ==11682==    by 0x102242D5: sqlite3OsInit (sqlite3.c:14162)
  ==11682==    by 0x1029EB28: sqlite3_initialize (sqlite3.c:107299)
  ==11682==    by 0x102A159F: openDatabase (sqlite3.c:108909)
  ==11682==    by 0x102A1B29: sqlite3_open (sqlite3.c:109156)
  ==11682==    by 0x1021CAB0: sqlite3pp::database::connect(char const*) (sqlite3pp.cpp:89)
  ==11682==    by 0x1021C6E3: sqlite3pp::database::database(char const*) (sqlite3pp.cpp:74)
  </code></pre>
  
  <p>) so I have one thread that calls 2 similar functions of 2 difrent classes using <a href="http://code.google.com/p/sqlite3pp/" rel="nofollow noreferrer">sqlitecpp</a></p>
  
  <p>Functions look like this</p>
  
  <pre><code>void user_control::start_work_with_db( std::string db_name )
  {
      if (!is_db_set) // TODO: find out how to detach from one db and connect to another.
      {
          boost::shared_ptr&lt;sqlite3pp::database&gt; db_( new sqlite3pp::database(db_name.c_str())); //I could not get `db = new sqlite3pp::database(DB_name.c_str());` to compile
          db = db_;
          *lu &lt;&lt; "Connected to "&lt;&lt; db_name &lt;&lt; " database and created a table with SQLite return code: " &lt;&lt; db-&gt;execute(command_create_users_table.c_str()) &lt;&lt; log_util::endl;
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>void users_files_service::create_files_table( std::string db_name )
  {
      if(!is_db_set) // TODO: find out how to detach from one db and connect to another.
      {
          boost::shared_ptr&lt;sqlite3pp::database&gt; db_( new sqlite3pp::database(db_name.c_str())); //I could not get `db = new sqlite3pp::database(DB_name.c_str());` to compile
          db = db_;
          *lu &lt;&lt; "Connected to "&lt;&lt; db_name &lt;&lt; " database and created a table with SQLite return code: " &lt;&lt; db-&gt;execute(command_create_files_table.c_str()) &lt;&lt; log_util::endl;
          is_db_set = true;
      }
  }
  </code></pre>
  
  <p>and command_create_files_table looks like </p>
  
  <pre><code>command_create_files_table = "CREATE TABLE IF NOT EXISTS files (encoded_url varchar(300) UNIQUE NOT NULL primary key, file_name varchar(150) NOT NULL, user_name varchar(65) NOT NULL, is_public BOOLEAN NOT NULL, modified DATETIME NOT NULL default CURRENT_TIMESTAMP )";
  </code></pre>
  
  <p>and</p>
  
  <pre><code>command_create_users_table = "CREATE TABLE IF NOT EXISTS users (email varchar(100) UNIQUE NOT NULL primary key, pass varchar(100))";
  </code></pre>
  
  <p>and <code>db</code> is private member of each of classes.</p>
  
  <p>I wonder - do I have an error somewhere in presented code or SQLite does not suppor operating on 2 DB files from one thread?</p>