compile problem

Just starting out? Need help? Post your questions and find answers here.
robvw
New User
New User
Posts: 2
Joined: Wed Dec 06, 2023 9:43 pm

compile problem

Post by robvw »

I am a newby with Purebasic and have the following problem:
When I compile an example script 'database.pb' in de map "sources" I cannot open the resulting exe.
Maybe some commands must be added to 'database.pb'?
I found that the "debug" statement are ignored when creating an executable.
The script runs fine when I compile/run. How can I compile to a working .exe?
User avatar
mk-soft
Always Here
Always Here
Posts: 6329
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: compile problem

Post by mk-soft »

Welcome ;)

The example uses SQLite. The lib static is linked to the executable.

For MySQL, supply the libmariadb.[dll,so, dylib] with the executable. To do this, copy the libmariadb.dll file from the purebasic under the compilers folder and add it to the folder of your executable.

All lines containing debug are not compiled to the executable. Therefore it does not work.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: compile problem

Post by spikey »

Welcome. This should do what you want, I've sent the debug window output to a console window instead. You'll need to set the "Executable Format" to "Console" in the "Compiler Options" dialog before you compile.

Code: Select all

UseSQLiteDatabase()

Procedure CheckDatabaseUpdate(Database, Query$)
   Result = DatabaseUpdate(Database, Query$)
   If Result = 0
      PrintN(DatabaseError())
   EndIf
   
   ProcedureReturn Result
EndProcedure

OpenConsole("Database Example")

DatabaseFile$ = GetTemporaryDirectory()+"Database.sqlite"

If CreateFile(0, DatabaseFile$)
   CloseFile(0)
   
   If OpenDatabase(0, DatabaseFile$, "", "")
   
      CheckDatabaseUpdate(0, "CREATE TABLE food (name CHAR(50), weight INT)")

      CheckDatabaseUpdate(0, "INSERT INTO food (name, weight) VALUES ('apple', '10')")
      CheckDatabaseUpdate(0, "INSERT INTO food (name, weight) VALUES ('pear', '5')")
      CheckDatabaseUpdate(0, "INSERT INTO food (name, weight) VALUES ('banana', '20')")
      
      PrintN("SELECT * FROM food WHERE weight > 7")
      If DatabaseQuery(0, "SELECT * FROM food WHERE weight > 7")
      
         While NextDatabaseRow(0)
            PrintN(GetDatabaseString(0, 0))
         Wend
      
         FinishDatabaseQuery(0)
      EndIf
      
      CloseDatabase(0)
   Else
      PrintN("Can't open database !")
   EndIf
Else
   PrintN("Can't create the database file !")
EndIf

PrintN("Press Enter to end...")
Input()
robvw
New User
New User
Posts: 2
Joined: Wed Dec 06, 2023 9:43 pm

Re: compile problem

Post by robvw »

Hi Spikey,
Many thanks for your help !
Things work fine now.
Gratefully,
Rob
Post Reply