How to compile this (sqlite sample)

Moderator: Rathinagiri

Post Reply
User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

How to compile this (sqlite sample)

Post by Clip2Mania » Mon Sep 01, 2014 3:03 pm

Hi all,
I'm trying to compile the example attached (it's about sqlite) in HMG, but I can't get it working.
I keep on getting 'undefined reference to `sqlite3_xxxxx' errors :?

What should I do to make these errors go away?

Thanks,
Erik
Attachments
sqlite.rar
(41.95 KiB) Downloaded 141 times

pdhana
Posts: 9
Joined: Fri Jan 24, 2014 5:26 pm

Post by pdhana » Mon Sep 01, 2014 4:29 pm

Hi,

I could able to compile successfully. However there is an argument error which you may need to correct.


C:\hmg.3.3.0\SAMPLES\Projs\sqlite>type build.bat
@echo ON
cls
SETLOCAL
SET temp=%~dp0
SET stemp=%temp%&SET pos=0

:loop
SET /a pos+=1
echo %stemp%|FINDSTR /b /c:"SAMPLES" >NUL
IF ERRORLEVEL 1 (
SET stemp=%stemp:~1%
IF DEFINED stemp GOTO loop
SET pos=0
)

setlocal enableDelayedExpansion
set "temp1=%temp%"
set /a pos=pos-2

set temp=!temp1:~0,%pos%!

if "%1"=="" Goto WithOutPar
Set MainFile=%1
Goto Continue
:WithOutPar
for /R %~dp0%~1 %%f in (*.hbp) do (Set MainFile="%%~nf")
Goto Continue
:Continue


call %temp%\build.bat %MainFile%
Attachments
screen.png
screen.png (8.82 KiB) Viewed 1504 times

User avatar
Rathinagiri
Posts: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 142 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Mon Sep 01, 2014 5:26 pm

In your .hbc file, you have to include

libs=sqlite3
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Tue Sep 02, 2014 6:25 am

In your .hbc file, you have to include

libs=sqlite3
That's what I was missing. Thought it was some lib-thing, but didn't know where to put it! :)
Thanks, Mr. Rathinagiri!
Erik

User avatar
bpd2000
Posts: 964
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 137 times
Been thanked: 43 times

Post by bpd2000 » Tue Sep 02, 2014 9:55 am

Clip2Mania wrote:
In your .hbc file, you have to include

libs=sqlite3
That's what I was missing. Thought it was some lib-thing, but didn't know where to put it! :)
Thanks, Mr. Rathinagiri!
Erik
Add in hmg.hbc file located at c:\hmg\hmg.hbc
BPD
Convert Dream into Reality through HMG

User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Wed Sep 03, 2014 6:51 am

Add in hmg.hbc file located at c:\hmg\hmg.hbc
It happened to be the only lib which was "remmed out" (#) in hmg 3.3.1 (don't know why)

However, I still get following error (apparently cannot create the database)

I am using HMG 3.3.1 - 32 bits.
Should I recompile harbour or so?
Attachments
sqlite_err.jpg
sqlite_err.jpg (58.2 KiB) Viewed 1381 times

User avatar
gfilatov
Posts: 519
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 8 times
Been thanked: 72 times
Contact:

Post by gfilatov » Wed Sep 03, 2014 7:13 am

Clip2Mania wrote: However, I still get following error (apparently cannot create the database)

I am using HMG 3.3.1 - 32 bits.
Should I recompile harbour or so?
Hi,

No, it is not :?
There is a mistake in your calling the function MiscSql() - wrong a first parameter.

Please take a look for your updated module main_button_1_action.prg below:

Code: Select all

#include "hmg.ch"

declare window Main

Function main_button_1_action
public dbo := nil

if .not. file("nombre.db3")
   crearbase("nombre.db3")
   msginfo("BASE Creada")
   return nil
else
  dbo := connect2db("nombre.db3",.f.)
   If dbo == nil
       msginfo("no se puede conectar con la Base")
      return nil
   Endif
endif   

if ! iswindowactive(vnombre)
   Load Window vnombre

   datossqlite()

   vnombre.Center
   vnombre.Activate
endif
Return Nil


function crearbase(mDb)
  local sQry

  dbo := connect2db(mDb,.t.)
  if dbo == nil
     msgstop("File could not be created!")
     return nil
  endif
      
  // create table
  sQry := 'CREATE TABLE IF NOT EXISTS "personales" ("id" INTEGER PRIMARY KEY, "nombre" VARCHAR(55), "telefono" VARCHAR(15), "fecha" DATE);'  
  MiscSql(dbo, sQry)
return nil 
The program will work smoothly after above update 8-)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
mustafa
Posts: 603
Joined: Fri Mar 20, 2009 11:38 am
Location: Alicante - Spain
Been thanked: 47 times

Post by mustafa » Wed Sep 03, 2014 9:02 am

Hello Clip2Mania
Look at the Post:

viewtopic.php?f=6&t=1558&start=10" onclick="window.open(this.href);return false;
Sample_Sqlite.zip

Regards

Mustafa

User avatar
Clip2Mania
Posts: 99
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Wed Sep 03, 2014 9:53 am

Thanks Mustafa!

Problem is, I once downloaded this (nice) example, but wasn't aware of the updates :oops:
Thanks for helping me out! All works now.

Erik

Post Reply