Page 1 of 1

How to compile this (sqlite sample)

Posted: Mon Sep 01, 2014 3:03 pm
by Clip2Mania
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

Re: How to compile this (sqlite sample)

Posted: Mon Sep 01, 2014 4:29 pm
by pdhana
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%

Re: How to compile this (sqlite sample)

Posted: Mon Sep 01, 2014 5:26 pm
by Rathinagiri
In your .hbc file, you have to include

libs=sqlite3

Re: How to compile this (sqlite sample)

Posted: Tue Sep 02, 2014 6:25 am
by Clip2Mania
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

Re: How to compile this (sqlite sample)

Posted: Tue Sep 02, 2014 9:55 am
by bpd2000
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

Re: How to compile this (sqlite sample)

Posted: Wed Sep 03, 2014 6:51 am
by Clip2Mania
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?

Re: How to compile this (sqlite sample)

Posted: Wed Sep 03, 2014 7:13 am
by gfilatov
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-)

Re: How to compile this (sqlite sample)

Posted: Wed Sep 03, 2014 9:02 am
by mustafa
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

Re: How to compile this (sqlite sample)

Posted: Wed Sep 03, 2014 9:53 am
by Clip2Mania
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