SqLite on the cpp target - possible?

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

SqLite on the cpp target - possible?

cambiata
Someones using sqlite with the cpp target for desktop apps?
(There's Singmajesty's solution for Palm WebOS - could it work for desktop apps too?)

Jonas
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

Cauê W.
It should be easy to do it yourself!

Just add hx/CFFI.h as a header instead of neko.h at http://code.google.com/p/nekovm/source/browse/trunk/libs/sqlite/sqlite.c and follow the recomendations from http://haxe.org/doc/cpp/ffi 

Cheers! ; )
Cauê

2011/11/4 cambiata <[hidden email]>
Someones using sqlite with the cpp target for desktop apps?
(There's Singmajesty's solution for Palm WebOS - could it work for desktop
apps too?)

Jonas

--
View this message in context: http://haxe.1354130.n2.nabble.com/SqLite-on-the-cpp-target-possible-tp6962635p6962635.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

cambiata
Great! I'll give it a try.

Thank you, Cauê!
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

Cauê W.
If you run into any troubles post here an I'll be happy to help!


2011/11/4 cambiata <[hidden email]>
Great! I'll give it a try.

Thank you, Cauê!

--
View this message in context: http://haxe.1354130.n2.nabble.com/SqLite-on-the-cpp-target-possible-tp6962635p6962683.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

cambiata
Good to hear..! This is far far away from my as3 home..! :-)

Ok, I will try to "build" something here. What will the Build.xml target file be? A new "sqlite.ndll" file?
I guess that the neko sqlite.ndll is built using an equivalent Build.xml file. I've been looking to take it as a model, but haven't found it.

So, I guess that... (hold your breath!)

1.) I should create a Build.xml including the header-modified sqlite.c and sqlite.ndll as target. (Correct?)
2.) Use "haxelib run hxcpp Build.xml" to actually perform this build. (Correct?)
3.) Put the generated sqlite.ndll somewhere in /lib/hxcpp/? where it can be used by the compiler? (Correct? Not very, I suppose :-)

Hm. Am I in any sense on the right track in some part of this?
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

Cauê W.
2011/11/4 cambiata <[hidden email]>
Good to hear..! This is far far away from my as3 home..! :-)

 

Ok, I will try to "build" something here. What will the Build.xml target
file be? A new "sqlite.ndll" file?

Yes! : ) 
It can be either compatible with

I guess that the neko sqlite.ndll is built using an equivalent Build.xml
file. I've been looking to take it as a model, but haven't found it.

Actually neko's libs are built with neko's makefile. But I've made a sketch of what your buildfile should be here - it must work how it is


Note that I've already included to build the files you have to download from http://www.sqlite.org/download.html , you only have to put them in the same folder as your file. Also note that you'll have to rename your sqlite.c to sqlite.cpp (in order to build with c++ compiler). Also note that you'll have to have an ../ndll/ folder with the standard (Windows, Linux, Linux64, Mac, Mac64, iPhone...) directories
 

So, I guess that... (hold your breath!)

1.) I should create a Build.xml including the header-modified sqlite.c and
sqlite.ndll as target. (Correct?)
Right 
2.) Use "haxelib run hxcpp Build.xml" to actually perform this build.
(Correct?)
Right! 
3.) Put the generated sqlite.ndll somewhere in /lib/hxcpp/? where it can be
used by the compiler? (Correct? Not very, I suppose :-)
You can put it either:
  • in the same folder as your executable
  • create a new haxelib project and put inside a ndll folder there (this is the best way, so you can ensure it will work consistently)
  • you can also put inside the hxcpp lib folder, but I wouldn't recommend that option
 
Good Luck!

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

Cauê W.
Just a correction: here is the updated  build file

We shouldn't build shell.c : )

2011/11/4 Cauê Waneck <[hidden email]>
2011/11/4 cambiata <[hidden email]>
Good to hear..! This is far far away from my as3 home..! :-)

 

Ok, I will try to "build" something here. What will the Build.xml target
file be? A new "sqlite.ndll" file?

Yes! : ) 
It can be either compatible with

I guess that the neko sqlite.ndll is built using an equivalent Build.xml
file. I've been looking to take it as a model, but haven't found it.

Actually neko's libs are built with neko's makefile. But I've made a sketch of what your buildfile should be here - it must work how it is


Note that I've already included to build the files you have to download from http://www.sqlite.org/download.html , you only have to put them in the same folder as your file. Also note that you'll have to rename your sqlite.c to sqlite.cpp (in order to build with c++ compiler). Also note that you'll have to have an ../ndll/ folder with the standard (Windows, Linux, Linux64, Mac, Mac64, iPhone...) directories
 

So, I guess that... (hold your breath!)

1.) I should create a Build.xml including the header-modified sqlite.c and
sqlite.ndll as target. (Correct?)
Right 
2.) Use "haxelib run hxcpp Build.xml" to actually perform this build.
(Correct?)
Right! 
3.) Put the generated sqlite.ndll somewhere in /lib/hxcpp/? where it can be
used by the compiler? (Correct? Not very, I suppose :-)
You can put it either:
  • in the same folder as your executable
  • create a new haxelib project and put inside a ndll folder there (this is the best way, so you can ensure it will work consistently)
  • you can also put inside the hxcpp lib folder, but I wouldn't recommend that option
 
Good Luck!


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

singmajesty
At http://code.google.com/p/hxcpp-webos, I had SQLite working with the CPP  
target (though last I looked, it didn't seem to be defined in the build  
XML for some reason)

I have it on my to-do list to port the code to a separate NME extension. I  
haven't done it yet but it should be easy to do



On Fri, 04 Nov 2011 07:21:58 -0700, Cauê Waneck <[hidden email]> wrote:

> Just a correction: here is the updated  build file
> http://pastebin.com/ZZzSc0fP
>
> We shouldn't build shell.c : )
>
> 2011/11/4 Cauê Waneck <[hidden email]>
>
>> 2011/11/4 cambiata <[hidden email]>
>>
>>> Good to hear..! This is far far away from my as3 home..! :-)
>>>
>>
>>
>>
>>>
>>> Ok, I will try to "build" something here. What will the Build.xml  
>>> target
>>> file be? A new "sqlite.ndll" file?
>>>
>>
>> Yes! : )
>> It can be either compatible with
>>
>> I guess that the neko sqlite.ndll is built using an equivalent Build.xml
>>> file. I've been looking to take it as a model, but haven't found it.
>>>
>>
>> Actually neko's libs are built with neko's makefile. But I've made a
>> sketch of what your buildfile should be here - it must work how it is
>>
>> http://pastebin.com/X9rFraYp
>>
>> Note that I've already included to build the files you have to download
>> from http://www.sqlite.org/download.html , you only have to put them in
>> the same folder as your file. Also note that you'll have to rename your
>> sqlite.c to sqlite.cpp (in order to build with c++ compiler). Also note
>> that you'll have to have an ../ndll/ folder with the standard (Windows,
>> Linux, Linux64, Mac, Mac64, iPhone...) directories
>>
>>
>>>
>>> So, I guess that... (hold your breath!)
>>>
>>> 1.) I should create a Build.xml including the header-modified sqlite.c  
>>> and
>>> sqlite.ndll as target. (Correct?)
>>>
>> Right
>>
>>> 2.) Use "haxelib run hxcpp Build.xml" to actually perform this build..
>>> (Correct?)
>>>
>> Right!
>>
>>> 3.) Put the generated sqlite.ndll somewhere in /lib/hxcpp/? where it  
>>> can
>>> be
>>> used by the compiler? (Correct? Not very, I suppose :-)
>>>
>> You can put it either:
>>
>>    - in the same folder as your executable
>>    - create a new haxelib project and put inside a ndll folder there
>>    (this is the best way, so you can ensure it will work consistently)
>>    - you can also put inside the hxcpp lib folder, but I wouldn't
>>    recommend that option
>>
>>
>> Good Luck!

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

cambiata
In reply to this post by Cauê W.
Wow! # 1: Thank you for great help, Cauê!
Wow! # 2: I was not that completely far out in my theories!
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

Cauê W.
it seems Joshua's version should work great! : )

so just download http://code.google.com/p/hxcpp-webos/source/browse/trunk/hxcpp/runtime/libs/sqlite/SQLite.cpp , download also sqlite sources, and run that build.xml I sent you : )


2011/11/4 cambiata <[hidden email]>
Wow! # 1: Thank you for great help, Cauę!
Wow! # 2: I was not that completely far out in my theories!

--
View this message in context: http://haxe.1354130.n2.nabble.com/SqLite-on-the-cpp-target-possible-tp6962635p6962934.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

singmajesty
You can get the SQLite sources here:

http://code.google.com/p/hxcpp-webos/source/browse/trunk/hxcpp#hxcpp%2Fruntime%2Fthirdparty%2Fsqlite-3.7.5



On Fri, 04 Nov 2011 07:39:13 -0700, Cauê Waneck <[hidden email]> wrote:

> it seems Joshua's version should work great! : )
>
> so just download
> http://code.google.com/p/hxcpp-webos/source/browse/trunk/hxcpp/runtime/libs/sqlite/SQLite.cpp
> ,
> download also sqlite sources, and run that build.xml I sent you : )
>
>
> 2011/11/4 cambiata <[hidden email]>
>
>> Wow! # 1: Thank you for great help, Cauę!
>> Wow! # 2: I was not that completely far out in my theories!
>>
>> --
>> View this message in context:
>> http://haxe.1354130.n2.nabble.com/SqLite-on-the-cpp-target-possible-tp6962635p6962934.html
>> Sent from the Haxe mailing list archive at Nabble.com.
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

cambiata
Thank you, Cauê and Joshua! I'm getting closer here..!

I've created a github repo with the files that I've collected so far:
https://github.com/cambiata/haxe-cpp-sqlite

After adding the vc/bin to my environment path, I can kick off the compiling using "haxelib run hxcpp Build.xml".

However, compiling halts with the following message:
./sqlite.cpp(336) : error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'void *'
Context does not allow for disambiguation of overloaded function

Clue?
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

Cauê W.
hey!

It seems that there was another function called connect. probably at sqlite.c. I've been able to compile, here are the modified sources:

Just one warning: At the .hx sources, you need to change Lib.load("connect", "sqlite")  to Lib.load("sqlite_connect", "sqlite")

Cheers ;)
Cauê

2011/11/5 cambiata <[hidden email]>
Thank you, Cauê and Joshua! I'm getting closer here..!

I've created a github repo with the files that I've collected so far:
https://github.com/cambiata/haxe-cpp-sqlite

After adding the vc/bin to my environment path, I can kick off the compiling
using "haxelib run hxcpp Build.xml".

However, compiling halts with the following message:
./sqlite.cpp(336) : error C2440: 'type cast' : cannot convert from
'overloaded-function' to 'void *'
Context does not allow for disambiguation of overloaded function

Clue?

--
View this message in context: http://haxe.1354130.n2.nabble.com/SqLite-on-the-cpp-target-possible-tp6962635p6966077.html
Sent from the Haxe mailing list archive at Nabble.com.

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

cambiata
Now it compiles here too! :-)

Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

cambiata
...And now I can connect to a .sqlite with the code below, but it seems like there's an issue in Joshua's sqlite.cpp code.
The result_get_length method produces an error. Not very surprising beacuse the if(r->ncols != 0) neko_error(); statement below:

(sqlite.cpp)
static value result_get_length( value v ) {
   result *r;
   val_check_kind(v,k_result);
   r = val_result(v);
   if( r->ncols != 0 ) neko_error(); // ???     <<< Produces an Error : ERROR
   return alloc_int(r->count);
}

Note that the // ??? comment is not mine - it's in Joshua's file, line 207-208: http://code.google.com/p/hxcpp-webos/source/browse/trunk/hxcpp/runtime/libs/sqlite/SQLite.cpp

When just removing this columns check get an Int result (not an Error), but not the expected value of 4 rows in my table, but 1769406556...  

So, it seems like this has been an issue before in Joshuas code.

Clue?

Here's is my test Main.hx:

class Main
{
        private static var sqliteConnect = Lib.load("sqlite", "sqlite_connect", 1);
        private static var request = Lib.load("sqlite", "request", 2);
        private static var resultGetLength = Lib.load("sqlite", "result_get_length", 1);
        private static var resultGetNFields = Lib.load("sqlite", "result_get_nfields", 1);
        private static var resultGet = Lib.load("sqlite", "result_get", 2);
        private static var resultNext = Lib.load("sqlite", "result_next", 1);
       
        static function main()
        {
                var connection = sqliteConnect('E:/_dev/haxe/CppSqliteUse/bin/test.sqlite');
                var sql = "SELECT * FROM person";
                var result = request(connection, sql);
                               
                var nFields = resultGetNFields(result);  // Works!
                var firstField = resultGet(result, 0);  // Works!
               
                var length:Int = resultGetLength(result); // Gives an Error : ERROR !
                trace(length);
        }
}

Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

singmajesty
My files were modified from SQLite code for Neko, so there may be some  
loose ends to patch up. I'm not sure if I called result_get_length, but I  
do know I was able to access SQLite databases I had created using this code



On Sun, 06 Nov 2011 01:36:40 -0700, cambiata <[hidden email]> wrote:

> ...And now I can connect to a .sqlite with the code below, but it seems  
> like
> there's an issue in Joshua's sqlite.cpp code.
> The *result_get_length* method produces an error. Not very surprising
> beacuse the if(r->ncols != 0) neko_error(); statement below:
>
> (sqlite.cpp)
> static value result_get_length( value v ) {
>    result *r;
>    val_check_kind(v,k_result);
>    r = val_result(v);
>    if( r->ncols != 0 ) neko_error(); // ???     <<< Produces an Error :
> ERROR
>    return alloc_int(r->count);
> }
>
> Note that the // ??? comment is not mine - it's in Joshua's file, line
> 207-208:
> http://code.google.com/p/hxcpp-webos/source/browse/trunk/hxcpp/runtime/libs/sqlite/SQLite.cpp
>
> When just removing this columns check get an Int result (not an Error),  
> but
> not the expected value of 4 rows in my table, but 1769406556...
>
> So, it seems like this has been an issue before in Joshuas code.
>
> Clue?
>
> Here's is my test Main.hx:
>
> class Main
> {
> private static var sqliteConnect = Lib.load("sqlite", "sqlite_connect",  
> 1);
> private static var request = Lib.load("sqlite", "request", 2);
> private static var resultGetLength = Lib.load("sqlite",
> "result_get_length", 1);
> private static var resultGetNFields = Lib.load("sqlite",
> "result_get_nfields", 1);
> private static var resultGet = Lib.load("sqlite", "result_get", 2);
> private static var resultNext = Lib.load("sqlite", "result_next", 1);
>
> static function main()
> {
> var connection =
> sqliteConnect('E:/_dev/haxe/CppSqliteUse/bin/test.sqlite');
> var sql = "SELECT * FROM person";
> var result = request(connection, sql);
>
> var nFields = resultGetNFields(result);  // Works!
> var firstField = resultGet(result, 0);  // Works!
>
> var length:Int = resultGetLength(result); // Gives an Error : ERROR !
> trace(length);
> }
> }
>
>
>
> --
> View this message in context:  
> http://haxe.1354130.n2.nabble.com/SqLite-on-the-cpp-target-possible-tp6962635p6967143.html
> Sent from the Haxe mailing list archive at Nabble.com.
>


--
Using Opera's revolutionary email client: http://www.opera.com/mail/

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: SqLite on the cpp target - possible?

Cauê W.
Have you tried calling result_get_length on neko itself? It seems both would yield the same results

2011/11/6 Joshua Granick <[hidden email]>
My files were modified from SQLite code for Neko, so there may be some loose ends to patch up. I'm not sure if I called result_get_length, but I do know I was able to access SQLite databases I had created using this code




On Sun, 06 Nov 2011 01:36:40 -0700, cambiata <[hidden email]> wrote:

...And now I can connect to a .sqlite with the code below, but it seems like
there's an issue in Joshua's sqlite.cpp code.
The *result_get_length* method produces an error. Not very surprising
beacuse the if(r->ncols != 0) neko_error(); statement below:

(sqlite.cpp)
static value result_get_length( value v ) {
  result *r;
  val_check_kind(v,k_result);
  r = val_result(v);
  if( r->ncols != 0 ) neko_error(); // ???     <<< Produces an Error :
ERROR
  return alloc_int(r->count);
}

Note that the // ??? comment is not mine - it's in Joshua's file, line
207-208:
http://code.google.com/p/hxcpp-webos/source/browse/trunk/hxcpp/runtime/libs/sqlite/SQLite.cpp

When just removing this columns check get an Int result (not an Error), but
not the expected value of 4 rows in my table, but <a href="tel:1769406556" value="+551769406556" target="_blank">1769406556...

So, it seems like this has been an issue before in Joshuas code.

Clue?

Here's is my test Main.hx:

class Main
{
       private static var sqliteConnect = Lib.load("sqlite", "sqlite_connect", 1);
       private static var request = Lib.load("sqlite", "request", 2);
       private static var resultGetLength = Lib.load("sqlite",
"result_get_length", 1);
       private static var resultGetNFields = Lib.load("sqlite",
"result_get_nfields", 1);
       private static var resultGet = Lib.load("sqlite", "result_get",         2);
       private static var resultNext = Lib.load("sqlite", "result_next", 1);
       
       static function main()
       {
               var connection =
sqliteConnect('E:/_dev/haxe/CppSqliteUse/bin/test.sqlite');
               var sql = "SELECT * FROM person";
               var result = request(connection, sql);          
                               
               var nFields = resultGetNFields(result);  // Works!
               var firstField = resultGet(result, 0);  // Works!
               
               var length:Int = resultGetLength(result); // Gives an Error : ERROR !
               trace(length);
       }      
}



--
View this message in context: http://haxe.1354130.n2.nabble.com/SqLite-on-the-cpp-target-possible-tp6962635p6967143.html
Sent from the Haxe mailing list archive at Nabble.com.



--
Using Opera's revolutionary email client: http://www.opera.com/mail/


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org