flat assembler
Message board for the users of flat assembler.
Index
> Linux > SQLite |
Author |
|
kohlrak 08 Oct 2009, 23:33
You have to import it. The post just below this one has an example of importing SO files, but if you need something immediately that you don't have to worry too much about understanding, i have something in the macros section that'll help out. The example is for gtk, but i think you'll be able to use it. Though, with recent changes, it might be advisable to keep your eye out for future improvements to fasm itself.
|
|||
08 Oct 2009, 23:33 |
|
pelaillo 09 Oct 2009, 06:24
Here is a very simple example that uses the fasm's new features for ELF
Code: ;Use fasm 1.69 or later (for extended ELF support) SQLITE_OK =0 SQLITE_ROW =100 format ELF executable entry start include 'import32.inc' include 'proc32.inc' interpreter '/lib/ld-linux.so.2' needed 'libc.so.6','libsqlite3.so.0' import printf,exit,\ sqlite3_open,sqlite3_prepare_v2,sqlite3_step,\ sqlite3_column_text,sqlite3_finalize,sqlite3_close segment readable executable start: cinvoke sqlite3_open,database,ppDB cmp eax,SQLITE_OK jne .error_opening cinvoke printf,msg1,database cinvoke sqlite3_prepare_v2,[ppDB],SQL1,SQL1_len,ppStmt,0 cmp eax,SQLITE_OK jne .error_compiling cinvoke sqlite3_step,[ppStmt] ; Creating a table cinvoke sqlite3_finalize,[ppStmt] cinvoke sqlite3_prepare_v2,[ppDB],SQL2,SQL2_len,ppStmt,0 cmp eax,SQLITE_OK jne .error_compiling cinvoke sqlite3_step,[ppStmt] ; inserting some records cinvoke sqlite3_finalize,[ppStmt] cinvoke sqlite3_prepare_v2,[ppDB],SQL3,SQL3_len,ppStmt,0 cmp eax,SQLITE_OK jne .error_compiling .get_row: cinvoke sqlite3_step,[ppStmt] cmp eax,SQLITE_ROW jne .rows_done cinvoke sqlite3_column_text,[ppStmt],0 cinvoke printf,text,eax cinvoke sqlite3_column_text,[ppStmt],1 cinvoke printf,text,eax jmp .get_row .rows_done: cinvoke sqlite3_finalize,[ppStmt] .closing: cinvoke sqlite3_prepare_v2,[ppDB],SQL4,SQL4_len,ppStmt,0 cmp eax,SQLITE_OK jne .error_compiling cinvoke sqlite3_step,[ppStmt] ; dropping the table cinvoke sqlite3_finalize,[ppStmt] cinvoke sqlite3_close,[ppDB] .the_end: cinvoke exit .error_compiling: cinvoke printf,msg2 jmp .closing .error_opening: cinvoke printf,msg3 jmp .the_end segment readable writeable ppDB dd 0 ppStmt dd 0 database db "tes.sqlite",0 SQL1 db "CREATE TABLE functions (name,description)",0 SQL1_len = $ - SQL1 SQL2 db "INSERT INTO functions VALUES ('hello', 'world')",0 SQL2_len = $ - SQL2 SQL3 db "SELECT * FROM functions",0 SQL3_len = $ - SQL3 SQL4 db "DROP TABLE functions",0 SQL4_len = $ - SQL4 text db "%s",0xA,0 msg1 db 'Sqlite3 test program. Reading "%s" database file.',0xA,0 msg2 db "Error compiling the SQL statement.",0xA,0 msg3 db "Error opening the database file.",0xA,0 Last edited by pelaillo on 08 Apr 2010, 13:59; edited 1 time in total |
|||
09 Oct 2009, 06:24 |
|
narada 09 Oct 2009, 13:52
+1) thanks.
+ some another question: for linux i am programming just few month, so i don't know some info. So, can i convert .so to .o ? |
|||
09 Oct 2009, 13:52 |
|
pelaillo 09 Oct 2009, 18:58
narada,
One .so file is a shared object (executable library) already linked and could be composed of several object files. The answer to your question is yes, but the method depends on what you really want to accomplish. |
|||
09 Oct 2009, 18:58 |
|
kohlrak 10 Oct 2009, 03:46
Odds are, if you're using linux and you have a .so file, there is a .o file in another folder or available for download.
I just did a little research on it and it's obviously open source, so by all means, dig in. Just make an object file instead and use a linker. |
|||
10 Oct 2009, 03:46 |
|
codesz 25 Nov 2009, 12:14
It works fine.
SQLITE_OK =0 SQLITE_ROW =100 |
|||
25 Nov 2009, 12:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.