News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Setting up SQLite

Started by bugmenot, February 16, 2009, 05:19:19 PM

Previous topic - Next topic

bugmenot

Hi, i have some questions about setting up sqlite.


  • I've downloaded sqlite-amalgamation-3_6_10.zip and tried to compile a static library with it. So i started a new Project ("Static Library") and added all the files included in the zip-file (sqlite3.c,  sqlite3.h, sqlite3ext.h). But all i got was sqlite3.o
  • I can't add a .o-file to the linker settings
  • How can i get it work?
  • Does it works with the .dll? How can i use it?

please help

thanks

Jenna

I just downloaded the sources, put them into the wizard-created project, and get a "*.a" file in the projects root-dir.

If you don't have it, your toolchain might be broken (missing ar.exe).

bugmenot

oh sry... yes there is also a ".a"  :oops:

Now i get on "Settings -> Compiler and Debugger... -> Linker settings" and "Project -> Build options... -> Linker settings" and add this file there right? Cause this doesn't work yet.

Jenna

Quote from: bugmenot on February 16, 2009, 06:52:32 PM
oh sry... yes there is also a ".a"  :oops:

Now i get on "Settings -> Compiler and Debugger... -> Linker settings" and "Project -> Build options... -> Linker settings" and add this file there right? Cause this doesn't work yet.


Normally you should not touch "Settings -> Compiler and Debugger... -> Linker settings", because the settings you make there are global to all projects, build with the compiler you have chosen.

The second is correct and should work. You can either use the absolute path here, or make sure the linker searchpath is set correctly. You can also youse the shortname of the lib (if serachpath is okay): if the library is called libsqlite.a it should be enough to use sqlite here.

You will of course need to include the header-files, to make the functions known to your sources.

Alfykun

I too am having the same issue,

I got the sqlite amalgamation zip and i tried to compile it to get the libsqlite3.a file but its just not happening..

can you please give me all the steps .. [complete noob]

I created a new project added the .c &.h files and tried to compile and it gives me this error

"undefined reference to 'Win Main@16'"


please help.


zabzonk

> "undefined reference to 'Win Main@16'"


That's the message you get if you created a windows GUI project - you want a static library.

Alfykun

Ohkay what do i do?

where can I change that?

zabzonk

> where can I change that?

When you first start CB, you get an option to create a new project - select that and then choose "Static Library" from the resulting dialog.


Alfykun

managed to make complie :) thanks

got a .a file which i renamed to libsqlite2.a and placed it into the lib folder and the .h file to the include folder.

tried to complie a simple connectivity program

#include<stdio.h>
#include<sqlite3.h>
#include<stdlib.h>

int main(int argc, char** args)
{
    // Create an int variable for storing the return code for each call
    int retval;

    // The number of queries to be handled,size of each query and pointer
    int q_cnt = 5,q_size = 150,ind = 0;
    char **queries = malloc(sizeof(char) * q_cnt * q_size);

    // A prepered statement for fetching tables
    sqlite3_stmt *stmt;

    // Create a handle for database connection, create a pointer to sqlite3
    sqlite3 *handle;

    // try to create the database. If it doesnt exist, it would be created
    // pass a pointer to the pointer to sqlite3, in short sqlite3**
    retval = sqlite3_open("sampledb.sqlite3",&handle);
    // If connection failed, handle returns NULL
    if(retval)
    {
        printf("Database connection failed\n");
        return -1;
    }
    printf("Connection successful\n");

    return 0;
    }



but i am getting this error now  :? "undefined reference to "sqlite3_open"

zabzonk

I don't know what you mean by the lib and include folders - it's best not to add anything to CB's own directories. Still, you need to:

- create a console application project
- write your main function
- from Project Build Options dialog add the directory containing the sqlite3.h header file to the "search directories" tab
- from Linker settings in the same dialog, use the add button to add the full name and path of your .a library file