Results 1 to 10 of 10

Thread: Problem linking Sqlite in vs9

  1. #1

    Exclamation Problem linking Sqlite in vs9

    Hi, I have a problem right now trying to work with the implementation of Sqlite in Clanlib v2.0.2 (althought I patched the includes and libs downloaded from the svn to have GL1 support). So I was wondering if one of you guys could help me and tell me what I'm doing wrong, this is the error message that I get:

    1>Linking...
    1>clanSqlite-static-mt-debug.lib(sqlite_connection.obj) : error LNK2019: extern symbol "public: __thiscall CL_DBConnection::~CL_DBConnection(void)" (??1CL_DBConnection@@QAE@XZ) unresolved ref in function "public: __thiscall CL_SqliteConnection::~CL_SqliteConnection(void)" (??1CL_SqliteConnection@@QAE@XZ)
    1>clanSqlite-static-mt-debug.lib(sqlite_connection.obj) : error LNK2019: símbolo externo "public: __thiscall CL_DBConnection::CL_DBConnection(class CL_DBConnectionProvider *)" (??0CL_DBConnection@@QAE@PAVCL_DBConnectionProvide r@@@Z) sin resolver al que se hace referencia en la función "public: __thiscall CL_SqliteConnection::CL_SqliteConnection(class CL_StringContainer<char,class CL_StringReference<char,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const &)" (??0CL_SqliteConnection@@QAE@ABV?$CL_StringContain er@DV?$CL_StringReference@DV?$basic_string@DU?$cha r_traits@D@std@@V?$allocator@D@2@@std@@@@V?$basic_ string@DU?$char_traits@D@std@@V?$allocator@D@2@@st d@@@@@Z)

    I tried to work around using the database.h file, but did not know how to implement, right now I was using the sqlite.h header and just coded this to test:

    CL_SqliteConnection db_connection("my_db.sql3");

    Right now i'm using the official Sqlite and works ok, not the one included in Clanlib, but I would like to use the one inside of Clanlib. If anyone could give me some help I will appreciete very much indeed.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    It seems it did not link with clanDatabase and then is complaining that there are things in clanSqlite that uses things from clanDatabase.

    Perhaps an error in our pragmas for clanSqlite? Try add #include <ClanLib/database.h> and see if it fixes the problem.

  3. #3

    Thumbs up

    Thanks for the reply, it didnt... it worked! really thanks, including database.h solved my problem, I cracked my head for about a day just for that.

    Ummm... other thing, if someone could post an example it could help me indeed, althought I am learning just with the classes right now, becouse there is no documentation in the page, althought, if I find the motivation, I will make it to complete the Clanlib doc.

  4. #4
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    I got some code lying around, its not complete, but it might help you get started. I cannot guarantee that any of this works

    Code:
    CL_SqliteConnection*connection = new CL_SqliteConnection(database);
    
    CL_DBTransaction transaction = connection->begin_transaction();
    CL_DBCommand command = connection->create_command("INSERT INTO Nodes (Label, PosX, PosY) VALUES (?, ?, ?");
    command.set_input_parameter_string(0, node->GetLabel());
    command.set_input_parameter_int(1, node->x);
    command.set_input_parameter_int(2, node->y);
    connection->execute_non_query(command);
    int rowid = command.get_output_last_insert_rowid();
    transaction.commit();
    
    CL_DBCommand command = connection->create_command("SELECT UserId, UserName, Password, RealName, CreateDate, LastLoginDate FROM Users WHERE UserId=?1");
    command.set_input_parameter_int(1, id);
    CL_DBReader reader = connection->execute_reader(command);
    while (reader.retrieve_row())
    {
    	int userId = reader.get_column_int(0);
    	CL_String userName = reader.get_column_string(1);
    	CL_String password = reader.get_column_string(2);
    	CL_String realName = reader.get_column_string(3);
    	CL_DateTime createDate = reader.get_column_datetime(4);
    	CL_DateTime lastLoginDate = reader.get_column_datetime(5);
    }
    reader.close();

  5. #5

    Default

    Nice, I will try it thks ^^

  6. #6

    Default

    Just for reference, the above code did not completely worked right, with some few changes I get to make this example.

    Code:
    		CL_SqliteConnection db_connection("my_db.sql3");
    
    		CL_DBTransaction transaction = db_connection.begin_transaction();
    		CL_DBCommand command = db_connection.create_command("INSERT INTO Nodes (Label, PosX, PosY) VALUES (?1,?2,?3);");
    		
    		command.set_input_parameter_string(1,"Cat");
    		command.set_input_parameter_int(2, 444);
    		command.set_input_parameter_int(3, 333);
    	        db_connection.execute_non_query(command);
    		transaction.commit();
    Of course you have to had previously created a database with the fields 'Label' (varchar) 'PosX' (integer) and 'PosY' (integer)
    Last edited by vladimirdlc; 07-14-2009 at 05:45 PM.

  7. #7
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Uhm, you never execute your command in that example. So it does nothing.

  8. #8
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Been using ClanLib's DB/SQLite these past few days.

    Friggin rules!

  9. #9
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    In the upcoming 2.0.3, there is now a SQL example show simple CRUD functionality of clanDatabase/clanSqlite.

  10. #10

    Default

    Quote Originally Posted by Magnus Norddahl View Post
    Uhm, you never execute your command in that example. So it does nothing.
    lol, true, I edited it, hope it works fine now ^^

Similar Threads

  1. MTDLL linking to clanSignal-static-mt.lib
    By BinarySpike in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 04-22-2009, 10:40 PM
  2. Help! linking error
    By thfai2000 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 10-30-2008, 04:30 AM
  3. Linking Problem With MS Visual C++
    By daredevil14 in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 07-27-2008, 11:44 PM
  4. Linking Problems.
    By TheBaron in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 11-16-2007, 08:22 PM
  5. Linking errors with VC++ Express 2005
    By lixopmstp in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 09-07-2007, 08:59 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •