Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have downloaded SQLite C/C++ interface to work with Cocos2d-x. Created a database by Firefox SQLite plugin. Then tried the following code

    // sqlite implementation
    sqlite3 *db;

    if(sqlite3_open("testdb.sqlite",&db) == SQLITE_OK){
        NSLog(@"Opened db Successfully");
    } else {
        NSLog(@"Failed to open");

Output is # Failed to open

How to solve the issue?

share|improve this question
up vote 1 down vote accepted

Well, you should start by checking the error code returned by sqlite3_open. Different codes are there for a reason to suggest what the error might be.

I for one guess that the file was not found. Very often the current directory is not what you expect, and is oftent different on different platforms.

share|improve this answer

I have written a blog on how to integrate sqlite in your cocos2d-x game in xcode step by step. You can visit

share|improve this answer
Welcome! If at all possible, could you try to include the most relevant information from your blog post? It helps ensure you have the best possible answer just in case your blog goes offline for any reason. – Mike C Mar 24 '14 at 21:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.