Build Failed: 'openssl.cypto.h' file not found , iOS project

I’m doing the source integration through Git (, but cannot get the right result.

There’s a similar question with this issue ‘openssl/rand.h’ file not found #146.
A answer in this issue say,use ./configure --enable-tempstore=yes --with-crypto-lib=commoncrypto CFLAGS=“-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2” ,but not work for me.

Do I need add the generated “splite3.c” to tartget’s compile Sources? If needed , there still the error message “Build Failed: ‘openssl.cypto.h’ file not found”.
if remove the .c file from compile Sources, the compilation process is fine,but sqlite3_key method always return “21”. the encyption is not work correctly.


Thanks for your interest in SQLCipher and for posting to the discussion forum.

Yes, you’ll need to add the generated sqlite3.c file to the target’s compile sources. From the error message I suspect you’re not adding the appropriate other c flags to the consuming project to specify that you’re using commoncrypto for SQLCipher: -DSQLCIPHER_CRYPTO_CC as mentioned in the documentation you linked: SQLCipher Community Edition - Adding Full Database Encryption for SQLite to iOS and macOS | Zetetic

Next, select your Project icon to bring up Project Settings, then select your Application Target from the left hand pane of the Project Settings and choose the Build Settings tab, and locate “Other C Flags.” Start typing “Other C Flags” into the search field until the setting appears, double click to edit it, and in the pop-up add the following value: -DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=3 -DSQLCIPHER_CRYPTO_CC -DNDEBUG . If there are any other specific build options you would like to enable or disable, add them to the C Flags.

it’s worked!
the way to config the parameter not familiar with me , after several attempts, finally I got the right config, the db is encrypted correctly.
thank u very much!!
there is another question occurs, how can I encrypt a existing db file? I already have a db storing mass data.

I wants to convert an existing standard SQLite database to an encrypted SQLCipher database, but some errors always happens
NSString * encryptKey = @“fwefefw13232fwfwxcfwefw13232fwfwxcfwefefw13232fwfwxcfwefw13232fwfwxc”;

    const char* sqlQ = [[NSString stringWithFormat:@"ATTACH DATABASE '%@' AS encrypted KEY '%@';", NewDBPath,encryptKey] UTF8String]  ;
    int test = sqlite3_exec(_dbEn, sqlQ, NULL, NULL, NULL);
    // i use the NewDBFIle Path
    const char*  sql2 =  [@"SELECT sqlcipher_export('encrypted');" UTF8String]   ;

    int exportOutcome = sqlite3_exec(_dbEn, sql2, NULL, NULL, NULL); // always 1
    int DETACHOutCome =  sqlite3_exec(_dbEn, (const char*) "DETACH DATABASE encrypted;", NULL, NULL, NULL);

this exportOutcome always return 1. There something wrong in my Code?

You’ll want to make sure an no file exists at the encrypted database path prior to performing the sqlcipher_export. I suspect this might be what’s causing the problem for you.

If that’s not the issue, I’d recommend printing the error message after running the sqlcipher_export to get some additional information i.e.:

        int rc = sqlite3_exec(db, "SELECT sqlcipher_export('encrypted');", NULL, NULL, NULL);
        if (rc != SQLITE_OK) {
            NSLog(@"SQLCipher export failed %s", sqlite3_errmsg(db));

done it.
the reason is dbEn that controls the new encrypted db.
I should operate in old db rather than new db.

thank u very much.

Yes. you should be running sqlcipher_export on the plaintext database connection with the attached encrypted alias as a parameter to go from plaintext → encrypted.

Glad to hear you were able to get it working.