I just tested this and at least on RedHat 5 the index on the library (ranlib or 
"s") doesn't make a difference.



You must be doing something wrong so please show your complete steps.



This works for me:



cc -c sqlite3.o

ar rvs libsqlite3.a sqlite3.o

cc -o mytest mytest.c -L. -lsqlite3 -lpthread -ldl



mytest.c:

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

int main()
{
  sqlite3 *db;
  sqlite3_stmt *stmt;
  int status;
  char *create = "create table test(a integer);";

  
status=sqlite3_open_v2("test.db",&db,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,NULL);
  if (status != SQLITE_OK)  {
    printf("open error:%s\n",sqlite3_errmsg(db));
    exit(1);
  }
  sqlite3_exec(db,create,NULL,NULL,NULL);
  return 0;
}



Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Sako Youssouf [youssouf.s...@renault-trucks.com]
Sent: Thursday, April 12, 2012 10:31 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] error compilation with Sqlite in C program

Michael I rebuild library and after I done the "ranlib" step but the same error 
occur!

Stephan I tried the change that you propose but the same error occur!

Others ideas?


-----Message d'origine-----
De : sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
De la part de Black, Michael (IS)
Envoyé : jeudi 12 avril 2012 17:17
À : General Discussion of SQLite Database
Objet : Re: [sqlite] error compilation with Sqlite in C program

You're missing a step in your library build.



ranlib libsqlite.a





Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Sako Youssouf [youssouf.s...@renault-trucks.com]
Sent: Thursday, April 12, 2012 10:10 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] error compilation with Sqlite in C program

Yes that what I tried but as you can see below when I do that, the first error 
reappear.

root@ubuntu:/home/y_sako/Documents/sqlite-amalgamation-3071100# ar -rv 
libsqlite.a sqlite3.o
ar: creating libsqlite.a
a - sqlite3.o
root@ubuntu:/home/y_sako/Documents/sqlite-amalgamation-3071100# gcc 
-L/home/y_sako/Documents/sqlite-amalgamation-3071100/ -lsqlite -L/usr/lib/ -ldl 
-lpthread -o compil compil.c
/tmp/cc7IDdvz.o: In function `main':
compil.c:(.text+0xc3): undefined reference to `sqlite3_open'
compil.c:(.text+0xda): undefined reference to `sqlite3_errmsg'
compil.c:(.text+0x101): undefined reference to `sqlite3_close'
compil.c:(.text+0x138): undefined reference to `sqlite3_exec'
compil.c:(.text+0x16d): undefined reference to `sqlite3_free'
compil.c:(.text+0x179): undefined reference to `sqlite3_close'
collect2: ld a retourné 1 code d'état d'exécution

-----Message d'origine-----
De : sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
De la part de Stephan Beal
Envoyé : jeudi 12 avril 2012 17:06
À : General Discussion of SQLite Database
Objet : Re: [sqlite] error compilation with Sqlite in C program

On Thu, Apr 12, 2012 at 5:00 PM, Sako Youssouf <
youssouf.s...@renault-trucks.com> wrote:

> compil.c:(.text+0x6f): multiple definition of `main'
>

Remove shell.o from your libsqlite.a.

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to