Re: [sqlite] Problem using loadable extension mechanism.

2006-09-15 Thread Christian Werner
jima wrote:
> 
> Hi,
> 
> I build **without** -DSQLITE_OMIT_LOAD_EXTENSION
> 
> I do ldd on sqlite3 and I get
> 
> libdl.so.2 => /lib/libdl.so.2 (0x00402000)
> 
> but I cannot load my Extension.so
> 
> Do Extension.c has to include sqlite3.h ?
> Presently I am only including sqlite3ext.h.

Including sqlite3ext.h is sufficient since it includes sqlite3.h.
As DRH wrote in an earlier posting it is essential to place the magic
macros in your extension source (SQLITE_EXTENSION_INIT1 outside of
any function, and SQLITE_EXTENSION_INIT2 at the beginnig of your
extension initialization function).

> If I have used --enable-thread at sqlite makefile configure time...can this
> cause an impact?

I don't think so; you linked your sqlite3 shell with -lpthread already,
right ? You can prove this with "ldd sqlite3"

HTH,
Christian

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Problem using loadable extension mechanism.

2006-09-15 Thread jima

Hi,

I build **without** -DSQLITE_OMIT_LOAD_EXTENSION

I do ldd on sqlite3 and I get

libdl.so.2 => /lib/libdl.so.2 (0x00402000)

but I cannot load my Extension.so

Do Extension.c has to include sqlite3.h ?
Presently I am only including sqlite3ext.h.

If I have used --enable-thread at sqlite makefile configure time...can this
cause an impact?

jima



2006/9/15, Christian Werner <[EMAIL PROTECTED]>:


jima wrote:
>
> Thanks for the advice but it would not work either. I just tried with
the
> flags you mentioned at compile time and full path when loading.
>
> Do you know if I have to enclose that full path in quotes or something
at
> load time? like...
>
> ..load '/path/Extension.so'
>
> ?
>
> I tried several combinations of quotes but no luck here.
>
> I will recheck all what I have been doing just to make sure there is not
an
> easy explanation for this...

Did you rebuild your sqlite3 shell without -DSQLITE_OMIT_LOAD_EXTENSION
and does an ldd on sqlite3 indicate that has libdl.so linked, e.g.

$ ldd ./sqlite3
...
libdl.so.2 => /lib/libdl.so.2 (0x00402000)
...

Then that sqlite3 shell command should do what you want:

$ ./sqlite3
...
sqlite> load './Extension.so'

HTH,
Christian


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




Re: [sqlite] Problem using loadable extension mechanism.

2006-09-15 Thread Christian Werner
jima wrote:
> 
> Thanks for the advice but it would not work either. I just tried with the
> flags you mentioned at compile time and full path when loading.
> 
> Do you know if I have to enclose that full path in quotes or something at
> load time? like...
> 
> ..load '/path/Extension.so'
> 
> ?
> 
> I tried several combinations of quotes but no luck here.
> 
> I will recheck all what I have been doing just to make sure there is not an
> easy explanation for this...

Did you rebuild your sqlite3 shell without -DSQLITE_OMIT_LOAD_EXTENSION
and does an ldd on sqlite3 indicate that has libdl.so linked, e.g.

 $ ldd ./sqlite3
 ...
 libdl.so.2 => /lib/libdl.so.2 (0x00402000)
 ...

Then that sqlite3 shell command should do what you want:

 $ ./sqlite3
 ...
 sqlite> load './Extension.so'

HTH,
Christian

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Problem using loadable extension mechanism.

2006-09-15 Thread jima

Better still, I have tried with full text search extension and I was able to
load it.

I will re-check my code. It is the most clear suspect now.

jima

2006/9/15, jima <[EMAIL PROTECTED]>:


I have them both...I read the wiki page before trying this myself. I will
try with the exact code that it is contained at the page.

Thanks for the hint.

jima


2006/9/15, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:

> jima <[EMAIL PROTECTED]> wrote:
> >
> > unable to open shared library [Extension.so]
> >
> > Any clues of what is going on?
> >
>
> Did you base your implementation of Extension.c off of the
> example C code contained in the wiki?
>
>http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
>
> The magic macros SQLITE_EXTENSION_INIT1 and SQLITE_EXTENSION_INIT2
> really are necessary for everything to work right.  Did you,
> prehaps, omit one or both?
>
> --
> D. Richard Hipp   <[EMAIL PROTECTED]>
>
>
> -
>
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>



Re: [sqlite] Problem using loadable extension mechanism.

2006-09-15 Thread jima

I have them both...I read the wiki page before trying this myself. I will
try with the exact code that it is contained at the page.

Thanks for the hint.

jima


2006/9/15, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:


jima <[EMAIL PROTECTED]> wrote:
>
> unable to open shared library [Extension.so]
>
> Any clues of what is going on?
>

Did you base your implementation of Extension.c off of the
example C code contained in the wiki?

   http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions

The magic macros SQLITE_EXTENSION_INIT1 and SQLITE_EXTENSION_INIT2
really are necessary for everything to work right.  Did you,
prehaps, omit one or both?

--
D. Richard Hipp   <[EMAIL PROTECTED]>



-
To unsubscribe, send email to [EMAIL PROTECTED]

-




Re: [sqlite] Problem using loadable extension mechanism.

2006-09-15 Thread drh
jima <[EMAIL PROTECTED]> wrote:
> 
> unable to open shared library [Extension.so]
> 
> Any clues of what is going on?
> 

Did you base your implementation of Extension.c off of the
example C code contained in the wiki?

   http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions

The magic macros SQLITE_EXTENSION_INIT1 and SQLITE_EXTENSION_INIT2
really are necessary for everything to work right.  Did you,
prehaps, omit one or both?

--
D. Richard Hipp   <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Problem using loadable extension mechanism.

2006-09-15 Thread jima

Thanks for the advice but it would not work either. I just tried with the
flags you mentioned at compile time and full path when loading.

Do you know if I have to enclose that full path in quotes or something at
load time? like...

.load '/path/Extension.so'

?

I tried several combinations of quotes but no luck here.

I will recheck all what I have been doing just to make sure there is not an
easy explanation for this...

Thanks again,

jima

2006/9/15, Christian Werner <[EMAIL PROTECTED]>:


jima wrote:

> ...
> And then I go, no problems building. I have sqlite built with this
> feature I guess.
>
> But the thing is that I cannot make it to work. I prepared a c file
> following the template given in the wiki. I generated a .so using:
>
> gcc -I/path_to_sqlite-3.3.7/src -c -o Extension.o Extension.c

Add the compiler switch -fPIC here.

> And
>
> gcc -shared -o Extension.so Extension.o/path_to_libsqlite3.so/libsqlite3.so

Omit libsqlite3.so here, there's no need for it in the extension.

> ...
> When I do in sqlite3 prompt:
>
> ..load Extension.so

Use the full path to Extension.so or prefix it with ./

Hope that helps,
Christian


-
To unsubscribe, send email to [EMAIL PROTECTED]

-




Re: [sqlite] Problem using loadable extension mechanism.

2006-09-15 Thread Christian Werner
jima wrote:

> ...
> And then I go, no problems building. I have sqlite built with this
> feature I guess.
> 
> But the thing is that I cannot make it to work. I prepared a c file
> following the template given in the wiki. I generated a .so using:
> 
> gcc -I/path_to_sqlite-3.3.7/src -c -o Extension.o Extension.c

Add the compiler switch -fPIC here.

> And
> 
> gcc -shared -o Extension.so Extension.o /path_to_libsqlite3.so/libsqlite3.so

Omit libsqlite3.so here, there's no need for it in the extension.

> ...
> When I do in sqlite3 prompt:
> 
> ..load Extension.so

Use the full path to Extension.so or prefix it with ./

Hope that helps,
Christian

-
To unsubscribe, send email to [EMAIL PROTECTED]
-