User forums > Help

Setting up SQLite

<< < (2/2)

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


--- Code: ---#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;
    }

--- End code ---


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


Navigation

[0] Message Index

[*] Previous page

Go to full version